Monday, June 11, 2012

Using form_tag in Ruby on Rails

In controller a "new" action creates a sample object that is just a simple object, not ActiveRecord :

  def new
    @item = Item.new
  end

"Create" action is a post action

  def create
  end

And in the view the following code just displays Item object fields and posts back a hash with fields filled in on the client side:




This will create the following markup:

Relevant references:
http://guides.rubyonrails.org/form_helpers.html
http://www.tutorialspoint.com/ruby-on-rails/rails-html-forms.htm
http://www.saalonmuyo.com/2010/01/27/using-form_tag-in-ruby-on-rails

0 коммент.:

Post a Comment

Powered by Blogger.