Reply to comment

Ruby on Rails, odd behaviour with common terms

I added a 'display' property to my job model to determine if that job should be displayed in some graphs on the web application I was building. When I came to accessing that value using check_box('job', 'display') the checkbox remained blank no matter what value was in the underlying model. Odder still, if I selected the checkbox and submitted then the correct selected value would go through so I was getting an end-to-end from view to database it's just that the checkbox control was behaving oddly.

Based on some previous experience I changed the property name 'display' to 'show_in_graphs', with hindsight a better, more descriptive name anyway. Lo and behold everything now worked as expected. This isn't the first time that Rails has behaved oddly when common, presumably already-in-the-code-somewhere terms have been used.

I suspect with the code-by-convention nature of Rails then this sort of thing is hard to avoid, that said, I've done a fair amount of reading around rails and have yet to come across someone telling me to watch out for this kind of thing so if you've read this far then 'watch out for this kind of thing'.

Your rating: None Average: 3 (1 vote)

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
Just checking your not a 'bot. Please answer the question below: