ruby on rails - Param is missing or the value is empty ROR -


good day, trying update rating of user using form_for populate text_field of current rating , update user entered value. far, seems simple doesn't seem , getting error. highly appreciated!

user controller:

def edit_rating       @ad = ad.find(params[:id])       @user = user.find(@ad.user_id)        if @user.update_attributes(user_params)         flash[:notice] = "user updated successfully"         redirect_to(:action => 'index')       else       end     end      def user_params       params.require(:user).permit(:firstname, :lastname, :email , :password , :location, :rating)     end 

edit_rating view:

<h2>     edit user rating </h2>  <h4>     name: <%= @user.firstname %> </h4>  <p>     current rating: <%= @user.rating%> </p>  <%=form_for(:user , :url => {:action => 'edit_rating' , :id => @user.id}) |f| %>      <p>         updated rating: <%= f.text_field(:rating) %>     </p>      <%= submit_tag("update rating") %> <% end%> 

this error getting.

enter image description here

you can reverse not permit can use params want use:

@user.update_attributes(rating: params[:user][:rating]) 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -