I am a newbie to ruby on rails. I was working on a project and run into an issue with a form. I am using devise for authentication. I have a user class which has admin and user roles. The devise generated add/ update methods for user is working properly. I am running into a 'No route matches [PATCH]' error when I am trying to create an edit page for the admins. here is the form I am using
<h4>Update Profile</h4>
<%= form_for @user, :url => {:controller => "admin", :action => "update" } do |f| %>
<%= hidden_field_tag(:id, @user.id) %>
<table>
<tr>
<td>First Name</td>
<td><%= f.text_field :first_name , :class => "form-control"%></td>
</tr>
<tr>
<td>Last Name</td>
<td><%= f.text_field :last_name , :class => "form-control"%></td>
</tr>
<tr>
<td>Email</td>
<td><%= f.text_field :email , :class => "form-control"%></td>
</tr>
<tr>
<td></td>
<td><%= f.submit "Update", :class => "btn btn-md btn-success pull-right" %></td>
</tr>
</table>
<%end%>
This is my controller method
def edit
end
def update
@user = User.find(params[:id])
if request.post?
if(@user.update_attributes(params[:first_name, :last_name, :email] ))
redirect_to :action => "admin_portal"
else
render :action => "edit"
end
end
end
I also have the route
get 'admin/update'
get 'admin/edit'
Can anyone suggest how I can fix this issue.