in my routes.rb I have a route

resources :projects do
member do
put "change_photo"
end
end

checked with rake routes CONTROLLER=projects
change_photo_project PUT /projects/:id/change_photo(.:format) projects#change_photo
from my projects#show I render a partial with a form in it
def show
@project = Project.find(params[:id])
..
end

VIEWS
projects/show.html.haml
.span4= render :partial => "projects/right_show"

projects/_right_show.html.haml
..
= form_for @project, :url => change_photo_project_path, :html =>
{ :multipart => true , :method => :put} do |f|
= f.file_field :photo
= f.submit t(:update)

this is working fine

Now I am trying to display the same partial from another controller ,
orders#new

orders_controller.rb
def new
@project = Project.find(params[:project_id])
end

VIEWS
orders/new.html.haml
.span4= render :partial => "projects/right_show"

but then I get a routing error
No route matches {:action=>"change_photo", :controller=>"projects"}
Try running rake routes for more information on available routes

I tried to pass the @project object
= render :partial => "projects/right_show", :object => @project

but no way , Routing Error ..
and the rake routes doesn't show me anything wrong or missing ...

where am I wrong ?

--
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.

Search Discussions

  • Colin Law at Mar 19, 2012 at 4:26 pm

    On 19 March 2012 16:12, Erwin wrote:
    in my routes.rb  I have  a route

    resources :projects  do
    member do
    put "change_photo"
    end
    end

    checked with rake routes CONTROLLER=projects
    change_photo_project PUT   /projects/:id/change_photo(.:format)         projects#change_photo
    from my  projects#show  I render a partial with a form in it
    def show
    @project = Project.find(params[:id])
    ..
    end

    VIEWS
    projects/show.html.haml
    .span4= render :partial => "projects/right_show"

    projects/_right_show.html.haml
    ..
    = form_for @project, :url => change_photo_project_path, :html =>
    { :multipart => true , :method => :put} do |f|
    = f.file_field :photo
    = f.submit t(:update)

    this is working fine

    Now I am trying to display the same partial from another controller ,
    orders#new

    orders_controller.rb
    def new
    @project = Project.find(params[:project_id])
    end

    VIEWS
    orders/new.html.haml
    .span4= render :partial => "projects/right_show"

    but then I get a routing error
    No route matches {:action=>"change_photo", :controller=>"projects"}
    Try running rake routes for more information on available routes

    I tried to pass the @project object
    = render :partial => "projects/right_show", :object => @project

    but no way ,   Routing Error ..
    and the rake routes doesn't show me anything wrong or missing ...
    Compare the generated html for the one that works and the one that
    doesn't (View > Page Source or similar in the browser) then you will
    see what the difference is and should be able to work out what is
    wrong.

    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.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedMar 19, '12 at 4:12p
activeMar 19, '12 at 4:26p
posts2
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Colin Law: 1 post Erwin: 1 post

People

Translate

site design / logo © 2021 Grokbase