开发者

Rails 3 route error

开发者 https://www.devze.com 2023-03-13 23:18 出处:网络
I am updating to apply dmarkow\'s suggestions. in my routes.rb: resources :userhome do member do get :edit_profile_picture

I am updating to apply dmarkow's suggestions.

in my routes.rb:

  resources :userhome do

    member do
      get :edit_profile_picture
    end

    member do
      post :update_profile_picture
    end

  end
开发者_高级运维

rake routes result:

edit_profile_picture_userhome
update_profile_picture_userhome

the link in the user home page:

<%= link_to "update profile picture", edit_profile_picture_userhome_path(@user) %>

controller:

  def edit_profile_picture
    @user = current_user
  end

error message:

No route matches {:action=>"edit_profile_picture", :controller=>"userhome"}

I missed the fact that i didn't change the name of my view to match my controller and route. I'm going to follow naming conventions more closely to help me avoid this kind of mistake.


You need to provide a Userhome ID or object to your path. Assuming that the currently-displayed Userhome is @userhome:

<%= link_to "update profile picture", profile_picture_userhome_path(@userhome) %>
0

精彩评论

暂无评论...
验证码 换一张
取 消