Trying to use the "smart" API for link_to def create_link(object, label = nil) label ||= auth_labels[:new] link = link_to(label, [:new, object]) if can?(:create, object) link.sub /new\./, 'new/' end
But this generates a link like /projects/new.1 , instead of /projects/ new I would assume it would make sense to pass it the class instead, like this, sense in this case the class itself should carry enough information to generate the path? def create_link(object, label = nil) label ||= auth_labels[:new] link = link_to(label, [:new, object.class]) if can?(:create, object) end But then I get: undefined method `new_projects_path' for #<#<Class:0x000001017f0ad8>: 0x000001017eebe8> If I substitute the key with :create it tries with create_projects_path which doesn't exist. What am I doing wrong here? Or is it a bug in edge rails? -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" 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/rubyonrails-core?hl=en.
