Thursday, May 5, 2011

Re: Re[Rails] stful routing seems excessive at times - I want to simplify

On 5 May 2011 06:21, clem_c_rock <clemrock@gmail.com> 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?

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

--
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate