On 6 August 2013 12:59, <[email protected]> wrote: > Hi > > I'm building a job board that uses a User model and a Job model. A user has > many jobs, and a job belongs to a user. > I need the board to act like this: > > If a user is logged in, he can see the jobs he created at > /users/:user_id/jobs. If a user is not logged in, he can see all the jobs > created by all users at /jobs.
You have not stated what a logged in user will see at /jobs and what a non-logged in user will see at /users/:user_id/jobs. Remember anyone can enter any url, and could put in an id for a different user. Why not just have one route and decide what to show based on whether the user is logged in or not? Colin > > > Currently I have 2 routes who route to the same index action. > > config/routes.rb > > resources :users do > resources :jobs, shallow: true > end > resources :jobs, only: [:index] > > rake routes > > user_jobs GET /users/:user_id/jobs(.:format) jobs#index > jobs GET /jobs(.:format) jobs#index > > Do I need the index action to conditionally check for the params[:user_id] > or is there a better way to accomplish this? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/3610385b-f8fa-4709-acb9-a433add7e1e9%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsiroyp1-qYtSs2pQqKVJoOZHQzOz-g4coVb8eiysBmBw%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.

