Please read for an updated status on RailsCasts:
Learn more or hide this
GitHub User: dideler
I just want to point out that you should use true and false for any boolean fields that you have. As seen in the ASCIIcast:
form.select :discontinued, [["Yes", true], ["No", false]]
You may be tempted to use 1 and 0 since those are the values used in the database for a TINYINT, but Rails will not show the correct default option for the select menu if you use integers. So make sure you use booleans!
Also, you can use search_field_tag instead of text_field_tag. That will create a text field of type "search".
Also, that last part about adding more fields to the search came in very handy, thanks! I was able to add a dropdown list to filter results in addition to the search.
Is this prone to SQL injection? It looks like you're directly embedding strings into your SQL queries.
For anyone who's using Rails 4 and is wondering about projects_path, don't worry. I'm a Rails newbie, but in my experience, Rails adds what you need to your routes file (app/models/modelname.rb) automatically when you create the controller.
If it doesn't, I believe adding the following line does it:
resources :projects # Replace "projects" with your controller name
Also, if you're wondering why we use def self.search instead of def search, it's because we want a class method instead of an instance method. In other words, it allows us to do Project.search, we're calling the method from the class, not from an instance of the class.
That probably means you're missing the search method in your model.
I noticed this screencast is pretty old. As some have mentioned, there's a faster faker (ffaker) now.
When I search through repos on GitHub, I noticed a lot of people are using the ffaker gem in their specs/ directory.
I'm new to Rails, and I'm not familiar with the specs/ directory yet. Is the info in this screencast still a good way to populate your DB with random fake data?