Ruby on rails form_tag - sending model parameters to controller

ajax, ruby, ruby-on-rails, ruby-on-rails-3

Solution

You have to do either of the following

<%= text_area_tag "micropost[content]", "", :size=> "20x2" %>

OR

<%= form_for :micropost, :url=>{ :controller => :microposts, :action => :create}, :remote => true do |f| %>
    <%= f.text_area :content, "", :size=> "20x2" %>
<% end %>

Problem

Controller: `@micropost = Micropost.new(params[:micropost])` But this form_tag is sending me `params[:content]` instead of `params[:micropost][:content]` ``` <%= form_tag( {:controller => :microposts, :action => :create}, :remote => true) do %> <%= text_area_tag :content, "", :size=> "20x2" %> ... ... ... <%= submit_tag "submit" %> <% end %> ``` server: ``` Processing by MicropostsController#create as JS Parameters: {"utf8"=>"✓", "content"=>"sdfsdf", "commit"=>"submit"} ```

Original source