Reputation: 299
routes.rb
-----------
resources :mail_settings
My form looks like this
the _form.html.erb
---------
<%= form_tag '/mail_settings' do %>
<div class="fieldBlock">
<%= label_tag :name %> <%= text_field_tag :name%> </div>
<div class="fieldBlock">
<%= label_tag :id%> <%= text_field_tag :id%> </div>
<div class="actions fieldBlock">
<%= submit_tag "Update Settings ", :class => "btn-large btn-success" %>
</div>
<% end %>
but I can access individual params like params[:name] without any problem, why is it not working when i try params[:mail_setting] ?
Upvotes: 1
Views: 402
Reputation: 7693
you mean why it is params[:name]
and not params[:mail_setting][:name]
? If so, the reason is that you are using form_tag
instead of just a form
, and family of *_tag helpers [ i.e. text_field_tag ]. In that case you do not 'bind' form to the model - in general form_tag is much more flexible than form. However, You should be able to do something like
<%= text_field_tag "mail_setting[name]"%>
and you will get params[:mail_setting][:name]
Hope I guessed what you asked about!
Upvotes: 2