ruby on rails 3 - ActiveResource, a model, and Form_Tag -


i trying use form_tag pass params captured form users controller. attempting communicate sinatra server, , not have database on client. view follows:

 <% form_tag(@user) %>  <div class="field"> <%= label_tag :first_mame %><br /> <%= text_field_tag :first_name  %> </div> <div class="field"> <%= label_tag :last_name %><br /> <%= text_field_tag :last_name %> </div> <div class="field"> <%= label_tag :email %><br /> <%= text_field_tag "user[email]" %> </div> <div class="field">   <%= label_tag :device_id %><br />   <%= text_field_tag "user[device_id]" %> </div> <div class="field"> <%= label_tag :type %><br /> <%= text_field_tag "user[device_type]" %> </div> <div class="actions"> <%= submit_tag %>  </div> <% end %> 

the create action on controller simply:

 def create  @user = user.new(params[@user])  @user.save  respond_to |format|   if @user.save     format.html { redirect_to(@user, :notice => 'user created.') }     format.json {render :json => @user }     format.xml  { render :xml => @user, :status => :created, :location => @user }   else     format.html { render :action => "new" }     format.xml  { render :xml => @user.errors, :status => :unprocessable_entity }   end end 

end

here's result => expected attributes hash, got nil

anybody know why? help.

  1. you need use form_for , not form_tag. form_for(@user) do
  2. in model need create schema. without rails doesn't know data enter form.
  3. when pass object parameter hash use :user , not @user. @user = user.new(params[:user])

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -