Ruby on Rails Saturday, February 2, 2013

Hi, I'm learning about routing and trying to solve the problem below.
Using update_scope_path in the view is routing to "users/show" rather
than users/update_scope, with "update_scope" becoming the user id.

( The goal is to change session[:question_scope] to "vip" when the user
clicks the button in the view. I assume I have to go to a controller
action to do that.)

In routes.rb:
resources :users
match '/users/update_scope', :to => 'users#update_scope', :as =>
:update_scope

In users_controller:
def update_scope
session[:question_scope] = "vip"
end

In users/show:
<%= link_to 'Go', update_scope_path, :class => 'btn btn-mini' %>

In debug params:
--- !ruby/hash:ActiveSupport::HashWithIndifferentAccess
action: show
controller: users
id: update_scope

--
Posted via http://www.ruby-forum.com/.

--
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 rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment