Hello there,
I am new around here and have been looking over the internet for a
solution but can't find one. I am fair new to rails but have a decent
understanding of it to get by and a few years experience behind me.
My problem is that I try to insert data in a database and it does not
come up. The information the user types is inserted however I wish to
insert the ID and other stuff the user can not change.
This is what I have so far:

The controller:

def create
    @postform = new(params[:postform])
    @post = Post.new(:title => @postform.title, :body => @postform.body,
:user_id => session[:user_id]).save
    respond_to do |format|
      if @post.save
        format.html { redirect_to(@post, :notice => 'Post was
successfully created.') }
        format.xml  { render :xml => @post, :status => :created,
:location => @post }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @post.errors, :status =>
:unprocessable_entity }
      end
    end
  end

View:

<h1>New post</h1>

<%= form_tag :action=>'create' %>
Title: <%= text_field("postform", "title",:size=>"20" ) %>
<br />
Body: <%= text_area("postform", "body",:size=>"20" ) %>
<br />
<%= label("postform", "user_id") %>
<br />
<input type="submit" value="Create" />

<%= link_to 'Back', posts_path %>

Error:

ArgumentError in PostsController#create

wrong number of arguments (1 for 0)

RAILS_ROOT: C:/Users/Jack/Documents/NetBeansProjects/BlogWithUser

Request

Parameters:

{"authenticity_token"=>"ubIO5KeB3WlLD+3hSoLBk4LJSuopsKrgureY6Uq4Rl0=",
 "postform"=>{"title"=>"adsf",
 "body"=>"adsf"}}

Thank you for your time
Jack
P.S. I tried with the standerd scaffold and that did not work ether (for
what I want to do)
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to