Please read for an updated status on RailsCasts:
Learn more or hide this
The validation part is what I looked for a long time, Ryan, thanks very much.
Very nice! How about revising episode #8 "Layouts and Content For" episode?
That'd be really awesome, I've took it for granted it hasn't changed that much, But I'm betting I'm wrong! I too want to see what awesome things you can do with content_for and content_tag
I have to do the price_in_cents stuff all the time, so I made priceable. Nothing too special, but still handy
I realise that you probably want to keep your examples simple and all in one file, but isn't creating categories or tags within the product model considered 'bad form'?
I'd love to see an episode with your take on the current OOP 'movement' in the Rails community - maybe a discussion on how and when you should use POROs etc.
You did some good episodes on design patterns like presenters etc. but a more general look at OOP would be great. Maybe even a multi-part series where you refactor a more complicated real world app?
Keep up the good work.
+1... I am hoping the next episode will be "Refactoring Virtual Attributes (and eliminating callbacks.)" I've been reading up a lot on this and think an episode will solidify the concepts!
When I first started using Rails, the virtual attributes episodes helped me heaps.
But as time goes, I start seeing my model class getting fatter and fatter, and becoming un-manageable (especially with all those AR callbacks). I guess it's a progressive advancement to start using PORO to move the logic out.
+1 for coverage of the Rails OOP movement & how to achieve fast tests
I would really like to see that also.
Btw, don't you guys think that many of these methods could be extracted into a Presenter?
Since they all affect the presentation of the information (they do not modify the data itself), I think would be much better to see it on a Presenter.
The same is not valid to Tag/Category creation, of course.
Not Ryan's take, but Gary Bernhardt at Destroy All Software has some great screencasts along those lines.
Tip: to check if a value is set on a field, Rails provides you with methods that end with a question mark. So your price_in_dollars method will look like this:
price_in_cents.to_d/100 if price_in_cents?
It's a small but neat change.
Also, speaking of prices, there is an excellent gem called money-rails for handling that: https://github.com/RubyMoney/money-rails
I, too, would like to see this. Otherwise, great episode, as always!
First of all: Great episode as always!
But I've got a question:
I tried to use the example from this episode with the creation of a new category in my app. I use internationalization there. Has anybody an idea how I could add the correct label to my text_field, without duplication inside my locales?
Does creating a new category belong in the model? - It seems a bit weird to have it in the model rather than the controller, or is it just me?
I have many price fields (monthly, average, total etc).
Can these getter/setter methods be rewritten for use with all my fields?
Wouldn't it be a good move to make the validation method private?
Virtual attributes don't activate callback functions in Rails 3.2.8
What am I missing? I cannot have a hour and min field convert to a duration model field.
attr_accessible :date, :hour_dur, :min_dur
attr_accessor :hour_dur, :min_dur
duration = hour_dur*60 + min_dur
duration / 60 if duration.present?
duration % 60 if duration.present?
First sign in through GitHub to post a comment.