Inject Data Members To An Object
This question is based on another question of mine(thankfully answered).
So if in a model I have this:
def self.find_extended person = Person.find(:first) complete_name = person.firstname + ', ' + person.lastname return person end
How can I inject complete name in the person object so in my controller/view I can access it by person.complete_name?
Thank you for your time,
I think the best way to do this is creation of complete_name attribute in your Person class:
def complete_name firstname + ', ' + lastname end
- → Trigger a click with jQuery using link_to of rails 4
- → Adding html data attribute to simple_forms input
- → How to remove parameters from the root URL if it does I18n
- → passing parameters to rails back end from an ajax call
- → Blocking ?page= in robots.txt
- → react js and rails Updating state on a component with active record relationship
- → State not passed into prop
- → Cannot read property 'modalIsOpen' of undefined
- → Objects not valid issue
- → How to map API params to model
- → Consuming webhooks shopify-api
- → How to add ScriptTag on shopify_api gem?