Topic: Super Frustrating

I'm using Rails 1.2.3.  I've successfully implemented RJS templates before but for the life of me I can't get them to work now.  Is it because I'm trying to be Restful?  I'm using nested resources and permalinks instead of ids.


/boats/show.haml

# This is the "/boats/fisherman" page
link_to_remote("Specs", :url => specifications_path(@boat))

Specifications Controller
def index
  @specifications = @boat.specifications.find(:all)
 
  respond_to do |format|
    format.html
    format.js
    format.xml {render :xml => @specifications.to_xml}
  end
end

/specifications/index.rjs
page.alert "Please work!"

Re: Super Frustrating

What's happening? nothing? some error?
What does your log say?

And where is @boat set? in some before_filter? bevause i don't see it created in the index action ...

Re: Super Frustrating

Nothing happens.  No alert box and nothing shows up in development.log.

Here's the before filter:

before_filter :get_boat

def index
  @specifications = @boat.specifications.find(:all)

  respond_to do |format|
    format.html
    format.js
    format.xml {render :xml => @boat.specifications.to_xml
  end
end

private

def get_boat
  @boat = Boat.find_by_permalink(params[:boat_id])
end


Here again, in the RJS template I'm just trying to see if it works.

page.alert "Please work."

And this is what I used for the link in the "/boats/fisherman" (/boats/show/1) view:

#RJS link that doesn't work
link_to_remote("Specs", :url => specifications_path(@boat))

#Regular link that does work
link_to("Specs", specifications_path(@boat))


Here's what the routes file looks like

map.resources :boats do |boats|
  boats.resources :specifications
end

Re: Super Frustrating

Just to clarify.  "fisherman" is the permalink of the boat with an id of 1.

Re: Super Frustrating

Never mind, I figured it out.  There was something in the development log I just didn't look closely enough.  The link_to_remote was sending a POST request?  Is that normal?  I solved it with this:

link_to_remote("Specs", :url => specifications_path(@boat), :method => "GET")

I would've guessed the other way around.  That it would be necessary to explicitly declare the POST method if that's what you wanted out of a link_to_remote.

Re: Super Frustrating

Yes that is normal.