How to use hidden_field to pass a parameter from new action to create action

I am calling the new action with the following:

= link_to 'Add Post', new_post_path(:user => { :user_id => params[:id] })

Such that the query string is:


And putting the following in the form partial:

    = f.hidden_field :user_id

But after submitting the form I get an error because the user_id is not being set in the params. What am I doing wrong?


You have to set the hidden field's value. See

In your controller:

@user_id = params[:user_id]

In your view:

  = f.hidden_field :user_id, @user_id

Need Your Help

how to ignore backing up certain tables with innobackupex


I am using innobackupex to back up my database but I need to ignore a few tables.

Can I convert the following code to use generics?

java generics comparison

I'm converting an application to use Java 1.5 and have found the following method:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.