Monday, 15 June 2015

ruby on rails - Route not working - very confusing -



ruby on rails - Route not working - very confusing -

i understand concept routes, , don't work should. in specific case i'm trying route editing project work, next error message:

no route matches [post] "/projects/8/edit"

routes.rb:

ampta::application.routes.draw "home/index" resources :sessions, only: [:new, :create, :destroy] match '/signin', to: 'sessions#new' match '/signout', to: 'sessions#destroy', via: :delete resources :projects collection "manage" end end resources :projects resources :tickets resources :projects_users resources :users root :to => 'home#index' end

controller:

class projectscontroller < applicationcontroller def edit // no code yet end end

view:

<% @users_projects.each |project| %> <%= link_to project.title, project_path(project), :class => "manage_project_link" %> <%= button_to "edit", edit_project_path(project), :class => "btn edit_button" %> <% end %>

what wrong? route found when running rake routes

edit_project /projects/:id/edit(.:format) projects#edit

look more closely error message:

no route matches [post] "/projects/8/edit"

it's using verb post , not get. that's why it's not finding route.

you using button_to helper generates form, default method beingness post.

you need alter button_to link_to.

ruby-on-rails ruby-on-rails-3 model-view-controller controller routes

No comments:

Post a Comment