How to get an Id value from association rails -


at time need , id value association because create new note, can assign note whoever want, have way

<%= f.association :user,         :label      => false,         :selected   => current_user.id,         :required   => true,         :input_html => {             :class      => 'span4',              :disabled   => true,              :style      => "float:right",              :id         => "usuario"} %> 

and controller create method way

 def create     @note = note.new(note_params)     @note.user_id = params[:user]     render :action => :new unless @note.save end 

but when press submit button save unless value column :user_id

i have tried params[:user_id] doesn't work

thanks , sorry english

first need remove attribute disabled field, disabled field isn't sended form (look @ disabled form fields not submitting data).

and, user_id should placed in params[:note][:user_id], take @ server log , search user_id right after send post server, there like:

started post "/note" ::1 @ 2013-07-18 15:22:34 +0000 processing notecontroller#create */*   parameters: {"note"=>{..., "user_id"=>"1", ...}} 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -