I love creating! It started with Lego as a little kid. Later I went on with (dis)assembling my first computer in the early 2000s. Then came the internet... Working remotely for 8 years :-)
Is never reached, because constantize raises an error if no constant with the given name exists. If you want to be able to return nil if no constant exists, use safe_constantize ;-)
One cool thing about strings in Ruby: you can easily extract substrings via regexs like this:
model=name[/([^\/.]*)_id$/,1]
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Is never reached, because
constantizeraises an error if no constant with the given name exists. If you want to be able to returnnilif no constant exists, usesafe_constantize;-)One cool thing about strings in Ruby: you can easily extract substrings via regexs like this: