I'm still trying to get used to REST concepts and forms
I have a very simple controller that updates user profile data. I have
this link that takes me to the controller:
<%= link_to('Profile', :controller => "operator_profile", :action => "edit")
%>
I then want to simply display the operator's data like this:
def edit
@operator = Operator.find(current_operator.id)
end
and I want a form that posts to a update method in operator_profile. in
my routes I have
resources :operator_profile
I feel like I'm completely locked into the 7 base methods of REST and
everything else throws routing errors
I couldn't even get the update method to work.
Can this be simplified?
--
View this message in context: http://old.nabble.com/Restful-routing-seems-excessive-at-times---I-want-to-simplify-tp31547496p31547496.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
Your example shows you attempting to use edit and update, which are
two of the standard routes, though in routes.rb you appear to be usin
:operator_profile but that should be plural :operator_profiles.
I am not sure exactly what you want to do, but if you just want to say
that you do not need the other routes then use
resources :operator_profiles, :only => [:edit, :update]
To see which routes you have defined then use
rake routes
If you have not already done so then have a good look at the Rails
Guide on routing. It will explain the above and much more.
Colin
resources :operations in routes
and in operations controller I have all 7 rest methods.
And now I'm getting this:
No route matches {:controller=>"operators", :action=>"edit"}
because of this link in application.html.erb:
<%= link_to('Profile', :controller => "operators", :action => "edit") %>
and when I do a rake routes - the only methods that are listed for operators
are:
operators GET /operators(.:format)
{:action=>"index", :controller=>"operators"}
POST /operators(.:format)
{:action=>"create", :controller=>"operators"}
My model is operator.rb
--
View this message in context: http://old.nabble.com/Restful-routing-seems-excessive-at-times---I-want-to-simplify-tp31547496p31549366.html
Please don't top post, it makes it difficult to follow the thread.
Insert your reply at appropriate points in previous message.
>
> Thanks for your help. I realized before I saw your reply that I should have
> made a operations_controller instead of the operator_profile_controller.
> So I did that and I now have:
>
> resources :operations in routes
Did you restart the server after changing routes.rb?
>
> and in operations controller I have all 7 rest methods.
>
> And now I'm getting this:
>
> No route matches {:controller=>"operators", :action=>"edit"}
>
> because of this link in application.html.erb:
>
> <%= link_to('Profile', :controller => "operators", :action => "edit") %>
What have you got in routes.rb for operators?
Colin
Thanks for your help. I realized before I saw your reply that I should have
made a operations_controller instead of the operator_profile_controller.
So I did that and I now have:
resources :operations in routes
and in operations controller I have all 7 rest methods.
And now I'm getting this:
No route matches {:controller=>"operators", :action=>"edit"}
because of this link in application.html.erb:
<%= link_to('Profile', :controller => "operators", :action => "edit") %>
and when I do a rake routes - the only methods that are listed for operators
are:
operators GET /operators(.:format)
{:action=>"index", :controller=>"operators"}
POST /operators(.:format)
{:action=>"create", :controller=>"operators"}
My model is operator.rb
View this message in context: http://old.nabble.com/Restful-routing-seems-excessive-at-times---I-want-to-simplify-tp31547496p31549366.html
clem_c_rock wrote:
>
>
> I'm still trying to get used to REST concepts and forms
>
> I have a very simple controller that updates user profile data. I have
> this link that takes me to the controller:
>
> <%= link_to('Profile', :controller => "operator_profile", :action =>
> "edit") %>
>
> I then want to simply display the operator's data like this:
>
> def edit
> @operator = Operator.find(current_operator.id)
> end
>
> and I want a form that posts to a update method in operator_profile. in
> my routes I have
>
> resources :operator_profile
>
> I feel like I'm completely locked into the 7 base methods of REST and
> everything else throws routing errors
>
> I couldn't even get the update method to work.
>
> Can this be simplified?
>
>
--
Sent from the RubyOnRails Users mailing list archive at Nabble.com.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-ta...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.