Use Non CRUD with Simply RESTful

Hey guys,

I’m trying out the new RESTful bits in Edge Rails, and am having a bit
of trouble wrapping my brain around certain things. For instance, say I
have a page that is separated into sections with tabs at the top. I want
to replace divs on the page with RJS.

Now typically before I’d have a method on the controller that rendered
an RJS template to accomplish this.

I’m not sure how to go about doing this with the new CRUD paradigm. I
can’t seem to use a regular link_to_remote tag as I get a routes error,
and I’m not sure what the syntax is to call a non CRUD method with
link_to_remote passing in an id param.

Any help would be great.

Thanks.

On 8/2/06, Guest [email protected] wrote:

I’m not sure how to go about doing this with the new CRUD paradigm. I
can’t seem to use a regular link_to_remote tag as I get a routes error,
and I’m not sure what the syntax is to call a non CRUD method with
link_to_remote passing in an id param.

I’m only just figuring this out, so I’m not 100% sure on this.

Assuming you have a default route (’:controller/:action/:id’) set up
in your routes.rb file, you should still be able to use link_to_remote
like you used to.

Additionally, you can use the :member option to add new named routes
that take an id:

map.resources :articles, :member => { :links => :get }

would let you do
links_article_url(@article)

If you don’t want it to apply to a particular object, you use the
:collection option:

map.resources :articles, :collection => { :links => :get }
links_articles_url

You then render RJS in that action. As I said, I’ve only picked this
up last night really. Those examples should all work, but I’m not
positive that it’s the correct way to use them in the first place.

Pat

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs