Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


difference between form_for and form_tag

Answers were Sorted based on User's Feedback



difference between form_for and form_tag..

Answer / arpita patel

form_for and form_tag both are used to submit the form in
ruby on rails.
but the way of handling objects related to model is
different.

form_for:

you should use form_for for a specific model i.e while
crating an new row in database. form_for will perform the
standard http post which is having fields related to active
record objects.

here is the example for using form_for in ruby on rails:

<% form_for :user, @user, :url => { :action => "update" }
do |f| %>

then in here you can use the f object to create input
field.

First name: <%= f.text_field :firstname %>
Last name : <%= f.text_field :lastname %>
Biography : <%= f.text_area :biography %>

<% end %>

form_tag:

form_tag just creates an form as an normal form. form_for
will perform the standard http post without any model
backed and has normal fields. this is used mainly when
specific things need to be submitted via form


here is the example for using form_tag in ruby on rails:

<% form_tag '/posts' do -%>
<%= text_field_tag "post", "firstname" %>
<% end -%>

Is This Answer Correct ?    54 Yes 3 No

difference between form_for and form_tag..

Answer / saravanan

The difference between the two is that form_tag just outputs
a <form>tag , It doesn't relies on activerecord object

and form_for gives you a means of accessing some wrapped object.

Is This Answer Correct ?    9 Yes 7 No

Post New Answer

More Ruby on Rails Interview Questions

How is visibility of methods changed in ruby (encapsulation) ?

0 Answers  


What is the difference between false and nil in ruby?

0 Answers  


how can we define Ruby regular expressions?

0 Answers  


Explain the various ide's of ruby on rails.

0 Answers  


What are the various components of rail?

0 Answers  


What are filters? and how many types of filters are there in ruby

2 Answers   Baidu, TCS,


Who designed active record in rails?

0 Answers  


I would like to know about ruby on rails.I want to know.how will be the future for ruby on rails.please tell me.

9 Answers   Baidu, TCS,


Explain how Rails implements Ajax?

0 Answers  


Explain dry in rails?

0 Answers  


Explain what are the servers supported by ruby on rails?

0 Answers  


Explain coc in rails?

0 Answers  


Categories