I''m looking for some thoughts (and +1''s!) on a patch (#713)
that
introduces two new Inflectors: Actionize and Parameterize.
http://rails.lighthouseapp.com/projects/8994/tickets/713-new-inflectors-actionize-and-parameterize
Actionize
Transforms a string in titleize() form to a string suitable for a
action name
"Expense Report".actionize # =>
"expense_report"
"My Totally Cool Action".actionize # =>
"my_totally_cool_action"
@reports = [''Expense Report'', ''Employee
Hours'']
@reports.each do |report_name|
link_to(report_name, "/reports/#{report_name.actionize}")
end
# => "<a href =
''/reports/expense_report''>Expense Report</a>
<a href = ''/reports/employee_hours''>Employee
Hours</a>"
Parameterize
Replaces special characters in a string so that it may be used as part
of a ''pretty'' URL.
==== Examples
class Person
def to_param
"#{self.id}-#{self.name.parameterize}"
end
end
@person = Person.find(1)
# => #<Person id: 1, name: "Donald E. Knuth">
<%= link_to(@person.name, person_path %>
# => <a href="/person/1-Donald_E_Knuth">Login</a>
Thanks!
Matt Darby, M.S.
Rails | PHP | Linux | MySQL | IT
Email: matt@matt-darby.com
Skype: matt-darby
Web: http://blog.matt-darby.com
--~--~---------~--~----~------------~-------~--~----~
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 rubyonrails-core@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-core-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---