Megazoor
Joined
Activity
Posted in jbuilder serializer for returning INDEX endpoint not working like it did with me.json.jbuilder ....
that works now thanks!!
I am wondering... if i wanted to pass the Signup data from the app directly to the rails api to signup or sign in without redirecting to the webview how would i go about that?
<3
Posted in jbuilder serializer for returning INDEX endpoint not working like it did with me.json.jbuilder ....
Hello! I finished your rails api - react-native demo and am begging for more react-native rails demonstrations... I am building a game with rails/react now using your tutorial as my base layer for using the api and setting up the env.
I have added an index var to the users class and am returning the proper json in /api/v1/index.json but when i try to add my serialzer its not recognizing it... i am still in the user class and have the route ad everything setup... wondering what im doing wrong?? Heres the code::
# users_controller.rb
def index
@index = render json: User.all, adapter: :json
end
# routes.rb
namespace :api do
namespace :v1 do
get '/me' => "users#me"
get '/index' => "users#index"
end
end
# /views/api/v1/users/index.json.jbuilder
json.array! @index do |user|
json.id user.id
json.email user.email
json.name user.name
json.avatar_url gravatar_image_url(user.email, size: 40)
end
Running
$ rails g scaffold Poop
returns:
Running via Spring preloader in process 13525
invoke active_record
create db/migrate/20181928173828_create_models.rb
create app/models/model.rb
invoke test_unit
create test/models/model_test.rb
create test/fixtures/models.yml
invoke resource_route
route resources :models
invoke scaffold_controller
create app/controllers/poops_controller.rb
invoke erb
create app/views/models
create app/views/models/index.html.erb
create app/views/models/edit.html.erb
create app/views/models/show.html.erb
create app/views/models/new.html.erb
create app/views/models/_form.html.erb
(erb):1:in template': undefined local variable or method
model_resource_name' for #Erb::Generators::ScaffoldGenerator:0x007fa59de06e48 (NameError)
from /Users/username/.rubies/ruby-2.4.1/lib/ruby/2.4.0/erb.rb:896:in eval'
result'
from /Users/username/.rubies/ruby-2.4.1/lib/ruby/2.4.0/erb.rb:896:in
When i run a scaffold i get this error:
(erb):1:in template': undefined local variable or method
model_resource_name' for #Erb::Generators::ScaffoldGenerator:0x007fa59de06e48 (NameError)
Please help, this is incredibly confusing...
Thanks i did just notice my api key changed and fixed that.
Also having this issue when i try to login from the client to my provider...
No route matches [GET] "/oauth/authorize"
Rails.root: /Users/username/project/my_client
thank you for your response, I removed the files i had created and ran the scaffold... now just getting this back
Started GET "/api/v1/tweets.json" for ::1 at 2018-10-02 03:37:14 -0400
Processing by Api::V1::TweetsController#index as JSON
Filter chain halted as :doorkeeper_authorize! rendered or redirected
Completed 401 Unauthorized in 1ms (ActiveRecord: 0.0ms)
@17:32
You did not show the process of creating the tweets.json scaffold... I realize you think you went over enough to have this be obvious but at this point its not, i went through and created all of the files manually you have in your repoistory but am getting
uninitialized constant Api::V1::TweetsController::Tweet
# GET /tweets.json
def index
@tweets = Tweet.all
render "tweets/index"
end
My solution was:
before_action :doorkeeper_authorize!, unless: :user_signed_in?
def current_resource_owner
@current_user ||= if doorkeeper_token
User.find(doorkeeper_token.resource_owner_id)
else
warden.authenticate(scope: :user)
end
end