Many of you know already that you may configure your inline actionlinks for singular associations columns.
Possible action values are :new, :show, :edit.
Let me show you a simple example. You would like to show “new” form in case player has nt got any team assigned and in case a team is assigned you would like to show “show” form
class PlayersController < ApplicationController
active_scaffold :player do |conf|
....
conf.columns[:team].actions_for_association_links = [:new, :show]
....
end
end
I m using it quite often, however sometimes I was missing the option to show list view. That s why you have the following options these days: :new, :show, :edit and :list.
class PlayersController < ApplicationController
active_scaffold :player do |conf|
....
conf.columns[:team].actions_for_association_links = [:new, :list]
....
end
end
Try it out. It s a shortcut for the user, all available information and actions for association model is just one click away and it s inline.
Apr 28, 2011 @ 16:05:39
How to active localize in spanish on Activescaffold ; i wanna change buttons [create] [create another (model)] ,etc
config.search.link.label = “Buscar” work very well
config.[button].label =”crear objetivo” ????
messages 1 Found => 1 Encontrado
Apr 29, 2011 @ 06:36:42
I would suggest to override activescaffold default ones in your config/locales/es.yml file, if you would like to change these for your whole application.
Jul 19, 2011 @ 22:49:07
is there an equivalent for Plural associations?
def plural_association?
self.association and [:has_many, :has_and_belongs_to_many].include? self.association.macro
end
Jul 20, 2011 @ 06:40:20
Not sure what you mean… I think I m missing the bigger picture of your question. This post is about actions_for_association_links…
Im not sure how your questions fits into that context…
Jul 20, 2011 @ 16:55:25
This only seems to effect singular associations columns. Is there something that does the same for Plural associations columns. The quoted text was from the code that differentiates between singular and and plural associations. Basically I want the action link for a column to always trigger :new or :create for the purpose of making quick log entries without having to see the whole list of log entries first.
Any thoughts?
Thanks for upgrading AS to rails 3 by the way.
Jul 23, 2011 @ 07:46:21
No, it s not possible for plural associations, but it s an interesting suggestion. However, it should be possible to create a member action_link, which calls create form of another controller.
Jul 26, 2011 @ 23:35:33
I do not really expect a solution and I am probably just talking to myself at this point.
I did have partial success with the member action_link. Where it did not work is that the new log entry was not connected to the Offering unless I did some back end trickery. Also the member row was not updated. Part of the issue is that the link generated by action_link is not that same as the New action of the log subform.
config.action_links.add(‘add logs’, {:action => ‘new’, :controller => ‘logs’, :type => :member, :page=>true})
results in this
http://rails.local/site_tracker/logs/new?id=2738
This is the full subform “Create new” link.
http://rails.local/site_tracker/logs/new?eid=offerings_2738_logs
The “eid” sends it down a much different path. I was able to fake the “eid” part the “id” persisted and as I said above the member row does not get updated and the new log row gets inserted at the top of the list of offerings.
Offering
has_many :logs
Logs
ffering
belongs_to
Once again thanks for you work getting AS to run on rails 3.
Jul 26, 2011 @ 23:54:25
hmm I seem to have learned some thing in last week. The following seems to work. It does not return to offerings list but it does link the new log entry to the offering.
config.action_links.add(‘add logs’, {:action => ‘new’, :controller => ‘logs’, :type => :member, :page=>true , :crud_type => :update ,:inline => true})
Jul 27, 2011 @ 06:16:20
Let me give you two hints:
1. Take a look at dynamic_parameters for action_links
2. Taka look at activescafffolds single table inheritance code and how action links are generated and processed later in edit or update action.
They are quite similar to your needs.