Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: ahnbizcad
You have to make sure in your model, you don't specify "counter_cache: true" when you're running your migrations. Otherwise, it throws "marked as read only" errors. It also does this when rolling back. So take note. I haven't been able to find a way around this. It seems you have to remove "counter_cache: true" when rolling back or migrating through a migration with counter_cache.
Wasted too much time just for a simple migration -_-
Also for rails 4, the syntax should be
Project.find_each.each do |p|
Project.update_attribute :tasks_count, p.tasks.length
update_counters, reset_counters, are all deprecated.
Note that the arguments syntax is different.
find_each is preferable because it executes in batches, not all at once.
So all that "complex" logic goes in the js files, and routing is done through angular. Does all of this make the rails functionality for these tasks redundant? How do you resolve or use both simultaneously?
so years later in rails 4, is Kaminari still better, cleaner, and frequently updated as will_paginate?
What is wrong with my coffeescript?
The JSON.parse line is causing the site to fail.
I cannot use var either.
$percentage_neti = JSON.parse($('#vote-data'))
$('.bar-neti').css("width", $percentage_neti + '%')
(the last two lines are indented)
Thank you so much. Simple, elegant, better.
How could you use the retrieved data as CSS attributes or element names?
Once I have the rails data in js, how would I use that value to set the width of a vote bar div to that calculated percentage value?
But I know the syntax is not right.
How could I also use the rails text data as the name of a class? If my rails data returns 52 via json, I want to select an element named $('#item-52') in js...
such impress. very thanks.
I think this is one of the very few resources out there that explains how rails is constructed. And it does so in the Ryan Bates's concise-yet-thorough style.
Having this primer will save so much time reading through the rails source code.
How would you implement chosen or select2 if your has_many through join table is not using the default id as a primary key? Is the syntax author_ids something rails handles automagically in the standard join table?
Thank you so much! The issue was pg using different query syntax. good to know!
I'm still having an issue where the existing tags don't show up when I go to the edit page.
Would you also need a comma after 'facebook'? If not, why?
Thank you so much, I've been looking for doing this with has_many :through for so long. I'm trying to work this with autocomplete as well. It's surprising how so few results there are for "has many through autocomplete" in a search.