ruby on rails - Noob error: No route matches [POST] "/users/1/edit" -


sooo... i'm noob , haven't found answer gets me through yet. i've been struggling through , know it's simple question, i'm not experienced enough know how solve one.

i'm receiving error:

no route matches [post] "/users/1/edit" 

here routes issue: (simple, know)

rails.application.routes.draw resources :users 

here controller:

class userscontroller < applicationcontroller   def new     @user=user.new   end    def create     @user = user.new(user_params)     if @user.save       redirect_to users_path     else       render 'new'     end   end    def edit     @user = user.find(params[:id])   end    def update     @user = user.find(params[:id])     if @user.update_attributes(user_params)       redirect_to @user     else       render 'edit'     end   end    def delete     @user = user.find(params[:id])   end    def destroy     @user = user.find(params[:id])     @user.destroy     redirect_to(:action => 'index')   end    def show     @user = user.find(params[:id])   end    def index     @users=user.all.order("created_at asc")   end    private      def user_params       params.require(:user).permit(:first_name, :last_name, :username, :admin, :email, :birthday)     end  end 

and, here view:

<doctype!! html> <html> <h1>edit user</h1>     <%= @user.username %>     <%= link_to "back user index", users_path %> <%= form_for(:user, :url => {:action => 'edit'}) |f| %>     <table summary="edit user form fields">         <tr>             <th>first name</th>             <td><%= f.text_field(:first_name) %></td>         </tr>         <tr>             <th>last name</th>             <td><%= f.text_field(:last_name) %></td>         </tr>         <tr>             <th>username</th>             <td><%= f.text_field(:username) %></td>         </tr>         <tr>             <th>password</th>             <td><%= f.text_field(:password) %></td>         </tr>         <tr>             <th>birthday</th>             <td><%= f.date_field(:birthday) %></td>         </tr>         <tr>             <th>is admin?</th>             <td><%= f.text_field(:admin) %></td>         </tr>     </table>  <%= submit_tag("update user") %>  <% end %> </html> 

i know not worth serious time answer, haven't been able figure out. please help, , let me know if need more info. again in advance!

change

<%= form_for(:user, :url => {:action => 'edit'}) |f| %> 

to

<%= form_for(@user) |f| %> 

in instance, don't need specify action use. default conventions in rails take care of you.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -