I am trying to figure how to break up a Get into 2 seperate views.
Scenario, user goes to index page and sees list of their posts with
links to show, edit, destroy.
Cool and working well.
However in the show portion there is not enough room to display all
the information. So in the show.rhtml page I have 90% of the
information, then I want to put a link at the bottom to take them to
the rest of the post information. Not sure how to do this restful
proper.
TIA
Stuart
I’m trying to creating a route for this option. I have
map.resources :positions, :collection => {:description => :show}
I believe that I need to create an action in the positions controller
called description
and then the helper url , should be description_position_path.
However I’m getting an exception:
NoMethodError in Positions#show
Showing app/views/positions/show.rhtml where line #73 raised:
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.to_sym
Not sure if this is the right approach and i’m doing something wrong
or this is the wrong approach completely.
Stuart
I guess it’s getting closer to figuring this out but I can still use
some help. Trying to create an action in my restful controller so I
can display more “show” information.
In my routes.rb -
map.resources :positions, :collection => {:description => :get}
In the “show.rhtml” , I’ve added a link to see the additonal information
<%= link_to ‘Show’, description_positions_path %>
In the action Description -
def description @position = Position.find(params[:id])
respond_to do |format|
format.html
format.xml {render :xml => @position.to_xml }
end
end
Leaving it like this allow me to load the first show page but when I
hit the description link - I get
Couldn’t find Position without an ID
yet if I go back to my link and do <%= link_to ‘Show’,
description_positions_path(position) %>
Then it won’t load the show.rhtml and gives me the error of undefined
variable or method.
Nope, when I try to do this I get
NameError in Positions#show
Showing app/views/positions/show.rhtml where line #73 raised:
undefined local variable or method `position’ for
#<#Class:0x6483738:0x6482c40>
I don’t get it , I’ve read the documentation 12x now so it looks like
this would work.
Nope, when I try to do this I get
NameError in Positions#show
Showing app/views/positions/show.rhtml where line #73 raised:
undefined local variable or method `position’ for
#<#Class:0x6483738:0x6482c40>
I don’t get it , I’ve read the documentation 12x now so it looks like
this would work.
Stuart
But this link does work:
<%= link_to “Preview Description”, :controller => ‘positions’, :action
=> ‘description’, :id => @position.id %>
And gives me a url of /positions/22;description , which I think looks
right ?
Stuart
Nope, dont be sorry. Actually the plural version renders a path but
without an id produce a “stack too deep” error, with (position) it
returns the same no method error.