On Oct 27, 2009, at 7:59 AM, LadyBug wrote:
>
> This may be more of a general Rails routing question but I have come
> across an interesting problem.
>
> In my test application I have a model, Project, and the associated
> ProjectController. The controller has the following declarations and
> they work just fine:
>
> hobo_model_controller
> auto_actions_for :owner, [:index, :new, :create]
> auto_actions :destroy, :edit, :show
>
> Now, I defined a totally new action in the controller, which basically
> generates some default stuff for my project:
>
> def new_default_model
> ...
> end
>
> And I put a link/button/whatever in my project table view to call that
> new action, like this:
>
> <controls:>
> <a class="new-link" with="&this"
> action="new_default_model" >New default model</a><br/>
> <a class="edit-link" with="&this" action="edit" >Edit</
> a><br/>
> <delete-button label="Remove project" update="self" />
> </controls:>
>
> Now, what happens is that both the edit link and the delete button get
> presented nicely, but the new_default_model action link is not. Just
> text, no link. Ok, a routing issue then. I added:
>
> map.project_new_default_model 'projects/:id/new_default_model',
> :controller => 'projects',
> :action => 'new_default_model',
> :conditions => { :method => :get }
>
> to my routes.rb. But this did not work. Just text is displayed, no
> link (i.e. no <a> tag at all).
>
The <a action=""> form is checking to see if the action specified
exists and is linkable. There's no good way to automatically read that
out of the manual routes, which is why that doesn't work. show_action
and friends add their actions to some internal Hobo arrays so they are
known.
Note that the action= attribute is a shortcut; you can always just use
href= and get plain HTML link behavior without magic.
--Matt Jones
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---