Ruby on Rails Monday, December 30, 2013

On 30 December 2013 15:06, João Paulo <lists@ruby-forum.com> wrote:
> Sorry Colin, I'll try to explain in a better way. In my system I have a
> variable called 'movie' and this 'movie' have a boolean attribute
> 'rented' that describes if this 'movie' was rented or not. I've created
> a scaffold to this variable and int this scaffold I put a new link to
> modify this attribute in this way:

Please remember to quote the previous message and insert your reply at
appropriate points.

> ...
> <td><%= link_to 'Rent', action: :rent, :id => movie.id %></td>
> # the link that I told
> ...

> ------------------------------------------> routes.rb
>
>
> Locadora::Application.routes.draw do
> resources :movies
>
> # The priority is based upon order of creation: first created ->
> highest priority.
> # See how all your routes lay out with "rake routes".
>
> # You can have the root of your site routed with "root"
> # root 'welcome#index'
>
> # Example of regular route:
> # get 'products/:id' => 'catalog#view'
>
> # Example of named route that can be invoked with purchase_url(id:
> product.id)
> # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
>
> # Example resource route (maps HTTP verbs to controller actions
> automatically):
> # resources :products
>
> # Example resource route with options:
> # resources :products do
> # member do
> # get 'short'
> # post 'toggle'
> # end
> #
> # collection do
> # get 'sold'
> # end
> # end
>
> # Example resource route with sub-resources:
> # resources :products do
> # resources :comments, :sales
> # resource :seller
> # end
>
> # Example resource route with more complex sub-resources:
> # resources :products do
> # resources :comments
> # resources :sales do
> # get 'recent', on: :collection
> # end
> # end
>
> # Example resource route with concerns:
> # concern :toggleable do
> # post 'toggle'
> # end
> # resources :posts, concerns: :toggleable
> # resources :photos, concerns: :toggleable
>
> # Example resource route within a namespace:
> # namespace :admin do
> # # Directs /admin/products/* to Admin::ProductsController
> # # (app/controllers/admin/products_controller.rb)
> # resources :products
> # end
> end
>
> ------------------------------------------> error in browser
>
> No route matches {:action=>"rent", :id=>1, :controller=>"movies"}

You have asked for action rent on the movies controller but you have
not provided a route for that.

I suggest you work right through a good tutorial such as
railstutorial.org (which is free to use online) which will show you
the basics of rails.

If you have a look at the Rails Guide on Routing then it will show you
how to do it, but best to work through the tutorial first.

Colin

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsbuTfyoJP9JQArVkyZpbbWTdTsOoj1g%3DtWXoHwbdePAA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment