I think at the moment, a good approach is to send data-route a
NamedRouteQuery,
which you can infer from an arbitrary controller action through
App.get('routes.controllerName.actionName').
You can also use App.get('currentRoute.controller') and
App.get('currentRoute.action') to get the current controller and action
strings.
On Wed Apr 25 14:15:32 2012, Anderson Florence wrote:
> So in my first look at data-route attribute, the github intro docs
> said it expected either a model instance or a model class. Because it
> didn't seem like it was designed to accept a controller action I was
> thinking it was determining its action based on the http verb.
>
> Later, I saw where you were talking about where some
> examples(classifieds) have used it as though it was a controller and
> action. Though the link for the demo of that example doesn't seem to work.
>
> Bottom line; I agree that it would be nice if we could get some
> clarification on how the data-route attribute is intended to be used.
>
> I did notice some recent commits regarding a new syntax for accessing
> named routes. I'm not sure if it is actually related or not
>
> Sent from my iPhone
>
> On Apr 20, 2012, at 10:46 AM, luxerama <
vin...@siebert.im
> <mailto:
vin...@siebert.im>> wrote:
>
>> This is not meant for API endpoins, so there is in REST nor CRUD
>> involved. I get your point if I was to, lets say create a CMS. The
>> routeTo filter is to be used when creating a batman.js application in
>> order to achieve things such as pretty URLs.
>> For example, I have a post which has a collection of attachments. Now
>> each attachment should have its on URL within the post like so
>> //posts/post-identifier/attachements/attachement-identifier/. This
>> would require me to have a URL with multiple arguments like the ones
>> described in the examples.
>>
>> I'm not sure if I have understood your argument completely, however I
>> cannot see this requirement to be anything out of the ordinary nor
>> can I see it breaking any conventions. The REST endpoints will all
>> stay the same, thus rails will be happy.
>>
>> On Friday, 20 April 2012 14:24:20 UTC+1, anderson_f wrote:
>>
>> It sounds like you're fighting the framework. Resources imply a
>> RESTful design where the http verbs imply the appropriate CRUD
>> action. Instead of using a 'new' action, you should do a POST to
>> '/foos'
>>
>> If you truly want it to route to a custom 'new' controller action
>> I would suggest just using a @route statement in the app.
>> However, for CRUD operations, you would be breaking RESTful
>> design best practices if you care about that sort of thing.
>>
>> Here is a link explaining how Rails Routes and Resources work:
>>
http://guides.rubyonrails.org/routing.html
>> <
http://guides.rubyonrails.org/routing.html>
>>
>> Sent from my iPhone
>>
>> On Apr 20, 2012, at 7:19 AM, luxerama wrote:
>>
>>> For anyone interested, I have created a helper that should be
>>> able to deal with most routing applications that are not covered
>>> by the tools provided by batman.js itself.
>>>
>>>
https://gist.github.com/2422262 <
https://gist.github.com/2422262>
>>>
>>> Please let me know if you have any questions/improvements or
>>> found problems with it.
>>>
>>> On Thursday, 29 March 2012 04:00:34 UTC+1, Matt Zukowski wrote:
>>>
>>> I'm super confused about how I'm supposed to be using routes
>>> in my views.
>>>
>>> For example, I have this in my app.coffee:
>>>
>>> |
>>> classMyAppextendsBatman.App
>>> @globalyes
>>>
>>> @controller'foos'
>>> @model'foo'
>>> @resources'foos'
>>> |
>>>
>>>
>>> Then under views/foos/index.html, I want to have a link that
>>> points to the "new" form. I've seen all of the following in
>>> examples:
>>>
>>> |
>>> <adata-route="foos#new">Add Foo</a>
>>> <adata-route="
routes.foos.new">Add Foo</a>
>>> <adata-route="/foos/new">Add Foo</a>
>>> |
>>>
>>>
>>> But none of these work. I just get <a href="#">Add Foo</a>.
>>> The only one I've managed to actually get working is:
>>>
>>> |
>>> <adata-route="{'controller':'foos','action':'new'}">Add Foo</a>
>>> |
>>>
>>> Seems kind of awkward, but whatever.
>>>
>>> Now I'm trying to add a link to the "edit" form for each
>>> Foo. And I can't get this to work at all. I've tried:
>>>
>>> |
>>> <divdata-foreach-foo="Foo.all">
>>> <adata-route="{'controller':'foos','action':'edit','id':
foo.id
>>> <
http://foo.id>}">Foo</a>
>>> <adata-route="{'controller':'foos','action':'edit','id':id}"data-bind-id='
foo.id
>>> <
http://foo.id>'>Foo</a>
>>> <adata-route="routes.foos[foo].edit">Foo</a>