RailsCasts Pro episodes are now free!

Learn more or hide this

Adam Stockland's Profile

GitHub User: atstockland

Comments by Adam Stockland


Im getting this error also. Im using simple_form...which doesnt seem to change anything. But, using Ryans code...getting the same validation error you were. What did you end up changing to get the validation to pass?


How would you type cast as a float rather than an integer?


Hi Ryan - I wanted to clarify how the object is used in can?. For example...say you have "@users.each do |u|"...with can? inside the loop. I notice many examples freely use either "User" or "u" as the object in can?. Is there a difference? It seems like calling the model as the object "can? :edit, User" would signify "current_user can edit users" whereas "can? :edit, u" would signify "current_user can edit this user"...since u is specific to a record and User is general to the model. Maybe Im putting too much thought in to this. Just wanted to clarify.



Hi Ryan. Has this changed at all in rails 3? My attr_accessor does not seem to be passing in the true/false value of the variable I set in the controller. I've tried everything and am beginning to think my problem might have to do with changes in Rails. Something is being blocked. Its such a simple thing...it driving me NUTS that its not just working!



Hi Ryan. I swear I had this working....maybe this is a rails 3.2.3 problem. Im getting a "undefined local variable or method" error on my form action. Everything is set up following your directions.

<%= form_tag require_certificatendorsements_path, :method => :put do %>

Any ideas?


As soon as I posted (#75) I realized the answer...at least one way of doing it. All I did to get the formtastic date field to default to today was to specify it in the new action. In my app it looks like this:

def new
@flight = Flight.new( :flightdate => Date.today )


Hi Ryan -
I notice that your born_on date field displays the current date by default in your app while using formtastic. My app doesnt do that.... I've added:

def after_initialize
      @flightdate ||= Date.today

to my model...but, I can't get my f.input :flightdate to display today by default...its just blank.

What can I do to make the formtastic date fields display today by default? Why did your app work as expected?

Thank you for all that you do! Your screencasts are invaluable. And, thanks to Justin too for creating formtastic...it is awesome.