Hey all,
I have two problems with this code. First, regardless of what option I
select from the dropdown menu, it only updates the record with id 1, and
second even if I just refresh the page, it still updates the record of id 1.
I basically just want to update the record that the user picks from dropdown
menu. But params[:id] is not doing the trick:
User Requests Controller:
def confirm
x = current_user.contact.contactable
@user_requests = UserRequest.find(:all, :conditions => ["location_id
?", x])
if @user_request = UserRequest.find(params[:id])
update_confirm
end
end
def update_confirm
@user_request.creator_id = current_user.contact.contactable
@user_request.save
end
end
confirm.erb form:
<% form_for(:user_request, :url => {:action => :confirm}) do %>
Request: <%= select_tag(:id,
options_from_collection_for_select(@user_requests, :id, :request_status_id))
%> <br />
Password: <%= password_field_tag :password %> <br />
<%= submit_tag ''Confirm Request'' %>
<% end %>
routes:
map.resources :user_requests, :member => {:confirm => :any}
For this part right here: if @user_request UserRequest.find(params[:id])
I would like to say something along the lines of if you have selected an
option from the dropdown menu, then we capture it before updating.
Any suggestions? Thanks.
--
View this message in context:
http://old.nabble.com/params-%3Aid--not-working-tp27556740p27556740.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.