Insert data into a database without user input

Jack Deadcore wrote:

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])

What is this and what do you expect from it? Do you have a "new" method
that takes one argument in your controller class? Also, the "new" method
of a controller simply renders a blank form to the browser so that the
user can fill it out.

Error:

ArgumentError in PostsController#create

wrong number of arguments (1 for 0)

Typically a controller contains a new method (action) that takes 0
arguments, hence the above error.

    @post = Post.new(:title => @postform.title, :body => @postform.body,
:user_id => session[:user_id]).save

P.S. Consider this instead:

@post = Post.create(:title => @postform.title, :body => @postform.body,
:user_id => session[:user_id])