![]() | ActiveRecord::ReadOnlyRecord |
|
21 Feb 2009, 19:21
Terry Brown (1 post) |
After populating the database using rake db:populate on the code from the 5th screencast, and reloading the server, I get a ActiveRecord::ReadOnlyRecord error when reloading the home page. ActiveRecord::ReadOnlyRecord in Movies#index Showing app/views/movies/index.html.erb where line #9 raised: ActiveRecord::ReadOnlyRecord 6: Run Time: <= movie.minutes %> minutes 7: 8: 9: <= display_stars(movie.average_stars) > 10: 11: 12: < end %> How do I fix this? |
|
15 Mar 2009, 18:51
Steve Downie (1 post) |
I just came across the same issue. Was this ever resolved? I’ve never come across this error before. Thanks, —Steve |
|
20 Mar 2009, 03:25
Ryan Bates (60 posts) |
Hi Terry and Steve, Sorry for not responding about this sooner. It seems records fetched with a :joins clause are now read only. There are a couple ways to get around this. One is to pass in a :select clause which seems to return writable records:
Another is to use :include instead of :joins. However this will probably not perform as well.
Hope that helps. Ryan |
|
28 Aug 2009, 16:13
Cyril (1 post) |
Hello, An other way is to disable readonly like so: |
|
03 Aug 2010, 19:34
David Blankenship (6 posts) |
I seem to be having a similar problem using Rails3 RC:
@event seems to still be readonly, even thought I specified it to not be read only on the find. I thought maybe it was current_user which was readonly, so I even placed readonly=>false in its original find. Ryan, you are right, if I use :select => “events.*” it is no longer read only. Just doesn’t look as nice to me. :D Still, better than it not working. |
| You must be logged in to comment |

