Hi,
Thanks for the screencast. The problem i am facing is that in the smtp settings you can have only one setting. e.g if I sometimes want to send a mail from gmail and another time from yahoo I have to change the settings in the production.rb or development.rb. How can i configure it, so i can use both the settings of yahoo and gmail(or any other) depending on from where the user wishes to send his mail.
Thank you.
hi ryan, great job as usual. quick question for you... when you are working around the inability to pass in a default value for the lamdba, you splat args and then in the proc you use "args.first || 2.weeks.ago"...
my question is why? why not just leave the argument to the lambda as "t" and then in the proc use "t || 2.weeks.ago" ?
seems to work for me, but i'm wondering if you had some other rationale for using the splat/first method.
I have the <%= javascript_include_tag :defaults %> line in the head of my projects.html.erb file and that changes nothing. This error seems a bit different than some of those that others have been getting. Can anyone spot what might be going wrong here, or should I post my code? So far as I can tell, I followed the code to the T, but alas...
Thanks in advance, and also, excellent screencasts Ryan!
@Quincy you likely downloaded the ".tar" file. You'll need to uncompress this. Once you do you'll end up with a folder with the plugin inside. Rename the folder to 'selenium-on-rails' and move it into your vendor/plugins directory and you should be good to go.
@Yuchen testing the visual look of the page would be hard to do programatically with any tool. You may want to try scripting Selenium to take a screenshot when going to certain pages. Then you can quickly review all of these. I haven't looked into this so I'm not sure how difficult/possible it is.
As for testing Javascript, Selenium can certainly do this (as I show in the episode) and I find it to be one of the big reasons to use it.
thanks for this screencast. I installed git and followed your screencast to submitted a patch - only to find later that my changes to files were in the patch, but the new file I had created wasn't included. I spent a bit of time this morning trying to figure out how to get that file included in the patch, but haven't had much luck yet. Is there a good resource for learning this stuff somewhere? A walk through for first timers?
Great article and a lifesaver BUT.. when you start doing things like time_select the custom forms_for_x is no longer rendered properly (namely the hidden fields generated by this time_select).. Not sure if this would effect other rails tags.. if so it's not as versatile as once thought and would have a limited use.
It is indeed useful to test the flow, from functionality perspective. But most of the time we have problem with different browsers that the visual presentation of web pages differ a lot. Say it looks most of the time OK in FF, but just bad in IE. And the javascript is not surely to work on different browsers either. Can Selenium help on those issues?
I can't install git on my laptop. It's an old Lombard with Panther 10.3. I downloaded the selenium-on-rails package from the github website, but I'm not sure how to install it. It includes one very long filename. Can anyone show me how to install it?
If you are using fields_for in the way that Ryan is in his code, Rails should provide a unique id. If that's not working, you could always pass your own id as an HTML attribute:
@Bryce, Selenium is great, but I don't think it will ever replace unit or functional tests. It works very well for testing the flow between multiple pages, javascript, and making sure the full stack of your app works. I would not use it for testing complicated business logic or numerous edge cases.
AFAIK, out of the box this doesn't work with autotest, but I'm sure it's possible to hack that functionality together somehow. I haven't tried.
I personally wouldn't find autotest support very useful. To me acceptance tests are something that don't have to be run as often as unit or functional tests. However I'm still trying to figure out how best to fit Selenium into my workflow.
I use Thomas' named_scope :conditions, proc { |*args| h = {}; h.store(:conditions, *args); h }
and I also have many named scopes already defined. I wish I could send a hash to a class method so that parsed arguments are wether sent to the right scope else to the default "conditions" method.
def self.search(*args)
args.extract_options!.stringify_keys.to_a.inject(scoped({})) do |scope, search|
scopes.include?(search.first) ? scope.send(search.first, search.last) : scope.conditions(search.first => search.last)
end
end
But this is really unstable, I can only mix a defined scope and the "conditons" and nothing more.
# this works
User.search( :name => "foo", :city_begins_with => "c")
# this not:
User.search( :name => "foo", :city => "chicago")
# this not either
User.search( :name_begins_with => "f", :city_begins_with => "c")
I got around the authentication by doing the following:
class Pie < ActiveResource::Base
self.site = "https://api.pie.com/"
def self.for_user(user)
self.site = "https://#{user}@api.pie.com/"
return self
end
end
rs = Pie.for_user(1).find(:all)
puts rs
One problem though is that you have to make sure after you use it to reset self.site to the correct url, otherwise there could be a security breach and you could access someone elses stuff elsewhere in your code. Something like this should really get built into ActiveResource
@James: hmm, as the cache_key will only bet updated when the BlogEntry object is saved, you'l have the same cache_key no matter if people added additional comments.
Now I know one could use a sweeper to clean the cache when a comment is added, but I thought the main reason for introducing cache_key is to shift from the paradigm of cleaning caches to updated object keys and have memcache clear the old data itself.
In other words, I'm still hoping for a blog entry/railscast with the title "5 smart ways of using cache_key", as I still can't clearly see its benefit.
@aleco - one usage that immediately occurs to me is loading a blog entry and its comments, where there's a counter cache recording the number of comments. With the new cache_key you can do:
okay, maybe I'm stupid, but I don't get how to properly use cache_key: how can I figure out its cache key without accessing the DB and getting the object itself? Here's an example:
An app has rather complicated, large objects, which should be cached. The first time a controller asks for the object with the id 1, it is read from the DB and then saved by its cache key. Now the next time the controller asks for the object with the id 1, the controller itself has no clue about its cache_key, so it can't find the object.
Is it really necessary to do a find(:select => [id, updated_at]) for that object, then generate the cache_key from the timestamp we now have, then check the cache if the object with this cache_key exists?
Somehow this feels ugly and completely wrong. But maybe I just don't get how people normally use the rails cache_key (and no, I'm not referring to the custom cache key from the rather old nubyonrails page that's linked above - that's something else).
I was having some issues with Rails 2.1 as well. When the errors were logged, I could not click the link to see the detail. Nothing happened. FireBug was showing me the output as RJS coming back but nothing happened. I followed Antonio Reina's suggestion above to add:
accepts.js { login_required_without_basic }
to my environments/production.rb file and that did the trick. However, I had already installed the RedCloth gem earlier but that would have mattered as well.
Nice and thanks so much had one question. I changed the search field to search for a date entered in a format of 2008-06-27 and it will return my results.
Changing this input text field to a date_select I cannot make it work. I see the three params but I continue to get
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
Will this inline type search work with date_select or select_date?
Thanks
Arni : Yes I didn't meant it was not possible, just it was not documented anywhere and as the different cache stores does not provides the same behavior, maybe it should be mentioned.
Thanx for creating a screencast for this gem of a feature. I otherwise would have missed it in the named_scope-and-friends frenzy of the rails 2.1 launch.
Just some bits I created after watching this episode:
With the presented conditions scope, you can only pass and array. I liked to pass any possible conditions "variant" (e.g. a hash) along and accomplished this with this little hack:
named_scope :conditions, proc { |*args| h = {}; h.store(:conditions, *args); h }
This way you say e.g.: SomeModel.conditions :some_attribute => value
Great videos guys!
One problem, I tried to:
script/generate scaffold existingmodel 'admin/existingmodel'
but I get
The name 'existingmodelHelper' is either already used in your application or reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
But then if we do it the first time like mentionned, it doesn't make sens, does it?
Since I'm using flex also, the edit and destroy way doesn't seem to be a good approach...?
Hey Ryan - thanks for the additional feedback. I'll look into building the development/non-development checks, but I wanted to make sure I hadn't missed anything obvious first.
As many have mentioned, looks like there's some problems with MemoryStore and FileStore. I encourage someone who has detailed this problem to submit a ticket/patch about it at rails.lighthouseapp.com. Looks like there's still a some work to do on them.
@JGeiger, looks like the hash brackets need to be specified when setting the namespace. I'll fix the code example.
@Carl, bypassing Rails through page caching is certainly the fastest caching technique out there, however it is not always practical depending on the app requirements. When deciding a caching technique, I usually go down this list and try the first one that seems like it will work well.
1. page caching
2. action caching
3. render caching (see link in show notes)
4. fragment caching
5. custom caching with Rails.cache
@Jochen, you can fetch the subcategories before putting it into the cache which will result in the subcategories being stored in the cache as well. Storing associations can get a little tricky because it can easily lead to stale data if it's not properly expired in each case.
@Jason, I think you'll have to build the "bypass cache in development" logic into your application itself. The Rails.cache method is so low level that Rails wouldn't know how to bypass it on its own. How would it know what to return on a cache.read? Maybe a config setting to flush the cache between each request in development would be sufficient?
Regarding your problem with it failing on the second request, this has to do with how memory_store keeps the classes which breaks with the "cache_classes = false" setting. I recommend using mem_cache_store until this is resolved.
@sibannac, you can use that all_cached method I created in this episode.
@categories = Category.all_cached
Just watch out as this will break with memory store and file store. You'll need to use mem_cache_store until those problems are resolved.
I had a lot of trouble getting this working as well. To have a bit more control over what was being logged, I merged the model, helper and controller from the plugin into my actual app. I placed the controller behind my admin auth so it inherited the security settings automatically. I also disregarded the exception_loggable.rb file and added a protected method in the application.rb file. Here's how it looks:
protected
def log_error(exception)
super(exception)
begin
LoggedException.create_from_exception(controller_name, action_name, request, exception)
rescue => e
puts "EXCEPTION: #{e.message}"
logger.error(e)
end
end
I am sure this is not the cleanest way to do it, but it does cut a lot of the fat away from the meat.
I'm trying to get this to work with Rails 2.1 and when run it locally following your instructions here, it works beautifully. However when I get it up on the server and try to start my mongrels I get 1/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:492:in `const_missing': uninitialized constant ApplicationController::ExceptionLoggable (NameError).
I'm not sure why it's not working. In my production.rb file I put what the README said, but it doesn't seem to find the EsceptionLoggable. Is there any more gem requirements besides will_paginate?
When I apply the code above to my application everything works on create and update but the update (edit) page displays the checkbox sets one time for every item checked.
So if I have three items checked when I edit a record then I have three sets of checkboxes displayed. Making a change to any one and saving works but I do not know how to stop it from looping through checked items and messing up the display.
... when initially calling MyClassName.all_cached and the next time it thinks the data is available in the cache, but retrieves nothing, breaking the view.
I had a look at the MemoryStore implementation and it's really only a simple hash. So any change made to an object from the cache will be visible to the next request. This is different to memcached where every object is (naturally) duplicated when being sent over the wire. Shouldn't perform the MemoryStore a "dup" on checkout to have the same semantics?
When you use this stuff in development, be mindful that when you've got config.cache_classes = false in your environment/development.rb file, then your model classes will be reloaded upon every request. Which means that the classes of the things in your cache don't actually exist anymore at the next request. This can lead to all sorts of errors.
Hi,
Thanks for the screencast. The problem i am facing is that in the smtp settings you can have only one setting. e.g if I sometimes want to send a mail from gmail and another time from yahoo I have to change the settings in the production.rb or development.rb. How can i configure it, so i can use both the settings of yahoo and gmail(or any other) depending on from where the user wishes to send his mail.
Thank you.
Ryan - Quick question, do you know why these don't work for virtual attributes that I've created using getter/setter methods? Thanks!
hi ryan, great job as usual. quick question for you... when you are working around the inability to pass in a default value for the lamdba, you splat args and then in the proc you use "args.first || 2.weeks.ago"...
my question is why? why not just leave the argument to the lambda as "t" and then in the proc use "t || 2.weeks.ago" ?
seems to work for me, but i'm wondering if you had some other rationale for using the splat/first method.
Howdy - I also have been having some issues getting this javascript to work. I'm running Rails 2.0 and using firefox.
Once I try to get the
"Add a task" button to work, I get the following error:
RJS error:
TypeError: element is null
new Insertion.Bottom("tasks", " \n \t\u003Cp\u003E\n\t Task: \u003Cinput id=\"project_task_attributes__name\" name=\"project[task_attributes][][name]\" size=\"30\" type=\"text\" /\u003E\n \t\u003C/p\u003E\n ");
I have the <%= javascript_include_tag :defaults %> line in the head of my projects.html.erb file and that changes nothing. This error seems a bit different than some of those that others have been getting. Can anyone spot what might be going wrong here, or should I post my code? So far as I can tell, I followed the code to the T, but alas...
Thanks in advance, and also, excellent screencasts Ryan!
Chris
@Quincy you likely downloaded the ".tar" file. You'll need to uncompress this. Once you do you'll end up with a folder with the plugin inside. Rename the folder to 'selenium-on-rails' and move it into your vendor/plugins directory and you should be good to go.
@Yuchen testing the visual look of the page would be hard to do programatically with any tool. You may want to try scripting Selenium to take a screenshot when going to certain pages. Then you can quickly review all of these. I haven't looked into this so I'm not sure how difficult/possible it is.
As for testing Javascript, Selenium can certainly do this (as I show in the episode) and I find it to be one of the big reasons to use it.
Hey Ryan,
thanks for this screencast. I installed git and followed your screencast to submitted a patch - only to find later that my changes to files were in the patch, but the new file I had created wasn't included. I spent a bit of time this morning trying to figure out how to get that file included in the patch, but haven't had much luck yet. Is there a good resource for learning this stuff somewhere? A walk through for first timers?
cheers, Loving your work as always.
Tim.
Great article and a lifesaver BUT.. when you start doing things like time_select the custom forms_for_x is no longer rendered properly (namely the hidden fields generated by this time_select).. Not sure if this would effect other rails tags.. if so it's not as versatile as once thought and would have a limited use.
It is indeed useful to test the flow, from functionality perspective. But most of the time we have problem with different browsers that the visual presentation of web pages differ a lot. Say it looks most of the time OK in FF, but just bad in IE. And the javascript is not surely to work on different browsers either. Can Selenium help on those issues?
For those with problems with collection_select, it's because the select helpers use the :index in the html_options hash. So what is normally:
collection_select :e_id, Exercise.find(:all), :id, :name, :index => nil
Becomes:
collection_select :e_id, Exercise.find(:all), :id, :name, {}, :index => nil
I spent a lot of time trying to figure this one out, too. Hope this helps someone with this problem!
I can't install git on my laptop. It's an old Lombard with Panther 10.3. I downloaded the selenium-on-rails package from the github website, but I'm not sure how to install it. It includes one very long filename. Can anyone show me how to install it?
Nice movie. Very helpful.
Do you intend t oupdate this for the current version? Would it be something like:
def self.up
create_table 'categories_products', :id => false do |t|
t.belongs_to :category
t.belongs_to :product
end
end
What the heck is kino trying to say?
@skoppy
If you are using fields_for in the way that Ryan is in his code, Rails should provide a unique id. If that's not working, you could always pass your own id as an HTML attribute:
f.check_box :property, :id => "some-unique-id"
I am struggling with passing an argument to my condition method. what if your in_us? was in_country? that took a country name?
@Bryce, Selenium is great, but I don't think it will ever replace unit or functional tests. It works very well for testing the flow between multiple pages, javascript, and making sure the full stack of your app works. I would not use it for testing complicated business logic or numerous edge cases.
AFAIK, out of the box this doesn't work with autotest, but I'm sure it's possible to hack that functionality together somehow. I haven't tried.
I personally wouldn't find autotest support very useful. To me acceptance tests are something that don't have to be run as often as unit or functional tests. However I'm still trying to figure out how best to fit Selenium into my workflow.
Hopefully we will see your forked changes incorporated back in to the plugin. Thanks for your work on this.
Thanks a lot Ryan for this intro to Selenium! What a great tool to compliment the current test suite and enhance UI testing.
Do you think this will eventually replace the built in rails test suite? Will it work with autotest?
Thanks again for the great screencasts
Bryce
Thanks for another excellent Railscast Ryan.
And thanks of course for the link :)
I'm having an issue with concatened scopes:
I use Thomas' named_scope :conditions, proc { |*args| h = {}; h.store(:conditions, *args); h }
and I also have many named scopes already defined. I wish I could send a hash to a class method so that parsed arguments are wether sent to the right scope else to the default "conditions" method.
def self.search(*args)
args.extract_options!.stringify_keys.to_a.inject(scoped({})) do |scope, search|
scopes.include?(search.first) ? scope.send(search.first, search.last) : scope.conditions(search.first => search.last)
end
end
But this is really unstable, I can only mix a defined scope and the "conditons" and nothing more.
# this works
User.search( :name => "foo", :city_begins_with => "c")
# this not:
User.search( :name => "foo", :city => "chicago")
# this not either
User.search( :name_begins_with => "f", :city_begins_with => "c")
Any idea ?
Nice! Running from a rake task it's very usefull!
Must try this!
FINALLY! I've been waiting for ages to have a good screencast on Selenium. Can't wait to see this.
Cheers, Ryan!
Just AMAZING!
if you know java and junit inside eclipse or other testing environments from other languages you really know how useful such and IDE can be.
Selenium is really really cool.
THX Ryan for that screencast.
oops, didn't closed the parenthesis after the subselect
tag is a Tag object which will be turned into an integer in this statement.
@Davis:
:conditions => "products.id IN (SELECT taggable_id FROM taggings WHERE tag_id IN(?) AND taggable_type = 'Products'", tag
@Ryan Townsend
@Ryan Bates
@Arya
I got around the authentication by doing the following:
class Pie < ActiveResource::Base
self.site = "https://api.pie.com/"
def self.for_user(user)
self.site = "https://#{user}@api.pie.com/"
return self
end
end
rs = Pie.for_user(1).find(:all)
puts rs
One problem though is that you have to make sure after you use it to reset self.site to the correct url, otherwise there could be a security breach and you could access someone elses stuff elsewhere in your code. Something like this should really get built into ActiveResource
This is a really good example, but it is now more easily accomplished with model_auto_completer:
http://agilewebdevelopment.com/plugins/model_auto_completer
@James: hmm, as the cache_key will only bet updated when the BlogEntry object is saved, you'l have the same cache_key no matter if people added additional comments.
Now I know one could use a sweeper to clean the cache when a comment is added, but I thought the main reason for introducing cache_key is to shift from the paradigm of cleaning caches to updated object keys and have memcache clear the old data itself.
In other words, I'm still hoping for a blog entry/railscast with the title "5 smart ways of using cache_key", as I still can't clearly see its benefit.
@aleco - one usage that immediately occurs to me is loading a blog entry and its comments, where there's a counter cache recording the number of comments. With the new cache_key you can do:
@entry = BlogEntry.find(params[:id])
@comments = Rails.cache.fetch(@entry.cache_key) { @entry.comments }
So you only need to fetch the one record from the database and then you know whether the cache will be good for all the dependent records.
okay, maybe I'm stupid, but I don't get how to properly use cache_key: how can I figure out its cache key without accessing the DB and getting the object itself? Here's an example:
An app has rather complicated, large objects, which should be cached. The first time a controller asks for the object with the id 1, it is read from the DB and then saved by its cache key. Now the next time the controller asks for the object with the id 1, the controller itself has no clue about its cache_key, so it can't find the object.
Is it really necessary to do a find(:select => [id, updated_at]) for that object, then generate the cache_key from the timestamp we now have, then check the cache if the object with this cache_key exists?
Somehow this feels ugly and completely wrong. But maybe I just don't get how people normally use the rails cache_key (and no, I'm not referring to the custom cache key from the rather old nubyonrails page that's linked above - that's something else).
I was having some issues with Rails 2.1 as well. When the errors were logged, I could not click the link to see the detail. Nothing happened. FireBug was showing me the output as RJS coming back but nothing happened. I followed Antonio Reina's suggestion above to add:
accepts.js { login_required_without_basic }
to my environments/production.rb file and that did the trick. However, I had already installed the RedCloth gem earlier but that would have mattered as well.
Nice and thanks so much had one question. I changed the search field to search for a date entered in a format of 2008-06-27 and it will return my results.
Changing this input text field to a date_select I cannot make it work. I see the three params but I continue to get
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
Will this inline type search work with date_select or select_date?
Thanks
@Jose - If your "keyboard doesn't behave well" wouldn't there be fewer posts from you?
Arni : Yes I didn't meant it was not possible, just it was not documented anywhere and as the different cache stores does not provides the same behavior, maybe it should be mentioned.
Thanx for creating a screencast for this gem of a feature. I otherwise would have missed it in the named_scope-and-friends frenzy of the rails 2.1 launch.
Just some bits I created after watching this episode:
With the presented conditions scope, you can only pass and array. I liked to pass any possible conditions "variant" (e.g. a hash) along and accomplished this with this little hack:
named_scope :conditions, proc { |*args| h = {}; h.store(:conditions, *args); h }
This way you say e.g.: SomeModel.conditions :some_attribute => value
Great videos guys!
One problem, I tried to:
script/generate scaffold existingmodel 'admin/existingmodel'
but I get
The name 'existingmodelHelper' is either already used in your application or reserved by Ruby on Rails.
Please choose an alternative and run this generator again.
But then if we do it the first time like mentionned, it doesn't make sens, does it?
Since I'm using flex also, the edit and destroy way doesn't seem to be a good approach...?
thanks
(btw I'm learning)
Thanks Ryan, so simple! I love your episodes so much. @Nicolás Sanguinetti thanks for the auto_discovery_link_tag.
Hey Ryan - thanks for the additional feedback. I'll look into building the development/non-development checks, but I wanted to make sure I hadn't missed anything obvious first.
As many have mentioned, looks like there's some problems with MemoryStore and FileStore. I encourage someone who has detailed this problem to submit a ticket/patch about it at rails.lighthouseapp.com. Looks like there's still a some work to do on them.
@JGeiger, looks like the hash brackets need to be specified when setting the namespace. I'll fix the code example.
@Carl, bypassing Rails through page caching is certainly the fastest caching technique out there, however it is not always practical depending on the app requirements. When deciding a caching technique, I usually go down this list and try the first one that seems like it will work well.
1. page caching
2. action caching
3. render caching (see link in show notes)
4. fragment caching
5. custom caching with Rails.cache
@Jochen, you can fetch the subcategories before putting it into the cache which will result in the subcategories being stored in the cache as well. Storing associations can get a little tricky because it can easily lead to stale data if it's not properly expired in each case.
@Jason, I think you'll have to build the "bypass cache in development" logic into your application itself. The Rails.cache method is so low level that Rails wouldn't know how to bypass it on its own. How would it know what to return on a cache.read? Maybe a config setting to flush the cache between each request in development would be sufficient?
Regarding your problem with it failing on the second request, this has to do with how memory_store keeps the classes which breaks with the "cache_classes = false" setting. I recommend using mem_cache_store until this is resolved.
@sibannac, you can use that all_cached method I created in this episode.
@categories = Category.all_cached
Just watch out as this will break with memory store and file store. You'll need to use mem_cache_store until those problems are resolved.
Looks my previous problems were caused by the :memory_store backend.
:file_cache also has some weird issue returning a string instead of an array
Finally it looks to work with :mem_cache_store.
I've run into a strange issue, while defining a local to_param method in my models for SEO purpose.
in short terms:
on cached model instances the "to_param" method is missing.
see: http://pastie.org/221873
I had a lot of trouble getting this working as well. To have a bit more control over what was being logged, I merged the model, helper and controller from the plugin into my actual app. I placed the controller behind my admin auth so it inherited the security settings automatically. I also disregarded the exception_loggable.rb file and added a protected method in the application.rb file. Here's how it looks:
protected
def log_error(exception)
super(exception)
begin
LoggedException.create_from_exception(controller_name, action_name, request, exception)
rescue => e
puts "EXCEPTION: #{e.message}"
logger.error(e)
end
end
I am sure this is not the cleanest way to do it, but it does cut a lot of the fat away from the meat.
I'm trying to get this to work with Rails 2.1 and when run it locally following your instructions here, it works beautifully. However when I get it up on the server and try to start my mongrels I get 1/vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:492:in `const_missing': uninitialized constant ApplicationController::ExceptionLoggable (NameError).
I'm not sure why it's not working. In my production.rb file I put what the README said, but it doesn't seem to find the EsceptionLoggable. Is there any more gem requirements besides will_paginate?
Great tool...
how can i cache an instance variable in controller?
like @products = Product.find(:all)
When I apply the code above to my application everything works on create and update but the update (edit) page displays the checkbox sets one time for every item checked.
So if I have three items checked when I edit a record then I have three sets of checkboxes displayed. Making a change to any one and saving works but I do not know how to stop it from looping through checked items and messing up the display.
<div class="agencytype">
<p>
<%= label :agencytype_form, :agencytype, "Agency Type" %>
<% for agencytype in Agencytype.find(:all) %>
<div>
<%= check_box_tag "profile[agencytype_ids][]", agencytype.id, @profile.agencytypes.include?(agencytype) %>
<%= agencytype.name %>
</div>
<% end %>
</p>
</div>
Is there something you need to do to bypass the cache write attempt in development mode? I've got:
config.cache_classes = false
config.action_controller.perform_caching = false
... set in my development.rb, but it still logs
Cache write (will save 0.00154): MyClassName.all
... when initially calling MyClassName.all_cached and the next time it thinks the data is available in the cache, but retrieves nothing, breaking the view.
Anyone else experiencing this?
I had a look at the MemoryStore implementation and it's really only a simple hash. So any change made to an object from the cache will be visible to the next request. This is different to memcached where every object is (naturally) duplicated when being sent over the wire. Shouldn't perform the MemoryStore a "dup" on checkout to have the same semantics?
@Sam: This can be used with memcached as the caching "engine", so it can hardly be "better than memcached§ when it used memcached ;)
When you use this stuff in development, be mindful that when you've got config.cache_classes = false in your environment/development.rb file, then your model classes will be reloaded upon every request. Which means that the classes of the things in your cache don't actually exist anymore at the next request. This can lead to all sorts of errors.
How to combine this with find_tagged_with from acts_as_taggable_on_steroids??
@Jonathan: Objects can easily be converted to and from strings (YAML and XML pop into mind).