Carlos Morales
Carlos Morales

Reputation: 1149

Other way to save params using rails?

I created a form to save information everything is working fine, but my question is if exists other way to save params?

Here is the view:

<% form_for @job, :url => {:controller=>"subject",:action=>'create'} do |f|%>
  <%= f.text_field :subject  %> 

  <%= text_field_tag "new_subject",:new_subject  %> 
<% end %>

Is there any other way to save Without f.text_field :new_subject ?

Here is the log

Processing SubjectController#create (for 127.0.0.1 at 2014-06-16 11:22:00) [POST]
Parameters: {"subject"=>{"subject"=>"This is a test"}, "new_subject"=>"This is other text", "commit"=>"Crea Factura", "authenticity_token"=>"LOL"}
Subject Columns (0.5ms)   SHOW FIELDS FROM `subjects`
SQL (0.1ms)   BEGIN
Test Create (0.2ms)   INSERT INTO `subjects` (`subject`, ` new_subject`, `created_at`, `updated_at`) VALUES('This is a test', NULL,'2014-06-16', '2014-06-16 16:22:00')
SQL (26.1ms)   COMMIT

Like the log says:

Is saving NULL because is not inside the first bracket

Also I tried:

<input id="new_subject" name="new_subject" type="text" />

Please somebody can help me?

Upvotes: 0

Views: 55

Answers (1)

mjhlobdell
mjhlobdell

Reputation: 371

Try this:

<input id="new_subject" name="subject[new_subject]" type="text" />

Upvotes: 1

Related Questions