I've got a few problems with an attr_accessor when using a form_tag in one my views.
<%= form_tag set_location_locations_path, :method => "post" do %>
<%= collection_select(:location, :location_id, Location.all, :id, :location_name) %>
<%= submit_tag "Go" %>
<% end %>
And in my location model I have this:
attr_accessor :location, :location_id
And I've also tried attr_writer for good measure.
When I submit the form, I can see this in my console:
ActionView::Template::Error (undefined method `location_id' for "1":String):
And the post looks like this:
Parameters: {"utf8"=>"✓", "authenticity_token"=>"oY+jSCV9Mz9iVJnJItADnHdpGhct5DhKpQ+w6JUvgNQ=", "location"=>{"location_id"=>"1"}, "commit"=>"Go"}
I can't figure out why this doesn't work? Previously I've used attr_accessor without problems. Is there something I'm missing?
---- EDIT ----
Controller (not much there)
def set_location
@location = params[:location][:location_id]
end
View not much here either:
= @location