ruby on rails - Simple form_for in the root page -


i "simple form" in root page in order update field in table.

<%= bootstrap_form_for @user |f| %>     <%= f.text_field :trig, label: "your trigram", :required => true %>     <%= f.submit :class => 'btn btn-primary btn-lg btn-block'%> <% end %> 

my route :

root 'static_pages#cvpage' put '/' => 'users#update' 

in users controller :

def update     @user = user.find(current_user.id)     @user.update_attributes(user_params)      if @user.save        redirect_to cvsindex_path     end end  def user_params     params.require(:users).permit(:trig) end 

but doesn't work. app goes blank page /users/6 have idea?

you need change <%= bootstrap_form_for @user |f| %> <%= bootstrap_form_for @user, :url => '/', :method => 'put' |f| %>

your resources :users should come after put '/' => 'users#update'

<%= form_for @user %> make path of new if @user object new record , update id object exist.

as practice should not use root path this. because updating can use path instead of root_path.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -