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))
%>
Password: <%= password_field_tag :password %>
<%= 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.