Very cool! I'd like to see more OM's in the NoSQL world to start using this, instead of cooking up their own!
Small caveat: ActiveModel defines before_validate and after_validate callbacks, but these aren't really usable: they're mixed up with the validations themselves, and invoked in the order they were defined. So, for example, if you declare a before_validate callback after a validates_presence_of, the before_validate will be called *after* the validation, which isn't very useful.
There's a change in edge now that moves before_validation and friends from ActiveRecord to ActiveModel to fix this, so expect that to make it to the release candidate.
Is it possible to just inherit from ActiveModel::Base?
If so, is there any good reason not to do this, instead of picking and choosing modules and having to dig through code to figure out which dependencies are missing?
Would also like response to dhc question. From some angles it looks like Rails 3 has a lot of features that come as a box of d-i-y components which you have to know how to assemble youself.
Surely this wasn't the point of Rails?
I think this is very dangerous...
send("#{name}=", value)
instead of including ActiveModel::Conversion module, extending ActiveModel::Naming module, and defining the persisted? method...
Another option would have been to change the form_for call in the view. Just change "form_for @message" to "form_for :message, :url => messages_path"
Would really like answer to dhc question, even if it makes me look even more stupid than I feel already.
@jonas, why? Rails does this in a similar way. Except all it does is check for protected attributes that shouldn't be mass assigned first and that the object responds to "#{key}=". If you want to add your own ability to have protected attributes, then go for it. I just don't think that's in the scope of this railscast.
http://github.com/rails/rails/blob/master/activerecord/lib/active_record/base.rb#L1532
Hey faithful Railscast fans:
I just wanted to point out that several of the spammers have websites that also allow comments.
I'm just sayin'...
Just an idea, totally unrelated to the screencast.
You could make a good use of p2p and give torrent links among with the usual download links.
@dhc (Since people are asking): You could define an "ActiveModel::Base" class and include the functionality you want for your app. The nice thing about the modular architecture is that you can do exactly what you are looking to do, but it's not forced upon you. So just define your own base class and include the modules you want for all of your inheriting classes. Don't get this confused with ActiveRecord, as that a different set of classes and modules, that happen to leverage the ActiveModel classes/modules.
Very nice screencast, Ryan! I had the same problem with ActiveRecord on rails 2 which requires some hacks in order to make the model not db specific. Great work on introducing ActiveModel! You mentioned downloading the rails 3 codes and read it. I just found out a neat tool that makes it easier to read codes from a source control system on your browser, it's called CodeFaces, here is the restful link to read the rails code on GitHub: http://codefaces.org/http://github.com/rails/rails
I made a gem called basic_model, based on this approach:
http://github.com/petebrowne/basic_model
http://rubygems.org/gems/basic_model
Just an idea, totally unrelated to the screencast.
You could make a good use of p2p and give torrent links among with the usual download links.
as that a different set of classes and modules, that happen to leverage the ActiveModel classes/modules.
Ryan, could you show the view that is calling this template?
This is one of the most incredible blogs Ive read in a very long time. The amount of information in here is stunning, like you practically wrote the book on the subject. Your blog is great for anyone who wants to understand this subject more. Great stuff; please keep it up!
Really like this website, this really helps and very useful. like you practically wrote the book on the subject. Your blog is great for anyone who wants to understand this subject more.
Seslichat Seslisohbet tescilpanel.com tescilpanel Sesli sistemler
Seslichat Seslisohbet tescilpanel.com tescilpanel Sesli sistemler
Good post. I am also going to write a blog post about this...I enjoyed reading your post and I like your take on the issue. Thanks.
love converse all star,love yourself.High quality low price.It's fit for you.
The information you provided was very useful. Because of your help, thank you.
Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming.
This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article
The blog article very surprised to me! Your writing is good. In this I learned a lot! Thank you!
Some times, to a certain need, we have to convert PDF to image for enjoyment.
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it. My readers have about the same interets
you provided was very useful. Because of your help, thank you.
Thanks for such a great post and the review, I am totally impressed! Keep stuff like this coming.
Great work on introducing ActiveModel! You mentioned downloading the rails 3 codes and read it. I just found out a neat tool that makes it easier to read codes from a source control system on your browser, it's called CodeFaces, here is the restful link to read the rails code on GitHub: http://codefaces.org/http://github.com/rails/rails
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it.
Thanks for sharing your article. I really enjoyed it. I put a link to my site to here so other people can read it.
There's a change in edge now that moves before_validation and friends from ActiveRecord to ActiveModel to fix this, so expect that to make it to the release candidate.
Good article! Thank you so much for sharing this post.Your views truly open my mind.
This is really a nice guide for Newbies like me. Thank you.






