Got it figured out. See even though I didn't have #raise_error_on_save_failure set to false, using create was leaving my object nil. I don't know, maybe it needs to be set to true to not effect the errors. I just thought true was the default. Now, that I am using new and save, errors are working.
On Monday, October 16, 2017 at 4:33:02 PM UTC-6, French Fry wrote: > > I've tried a number of things with no effect. The call to validation > errors is an undefined method. Can you please tell me what I am leaving > out? > > And if it's okay to double up, since `def new` instantiates a new Song > object, I wanted to use `set` in `def create_song` and it would not work. > Right now, while it works (minus the validation error issues) it's > essentially creating a new Song object twice. Originally I used insert, so > I replaced it with set, and then save, but no go. Ok, thank you for the > help! > > class Song < Sequel::Model > plugin :validation_helpers > self.raise_on_save_failure > > def validate > super > validates_presence [:title, :length, :released_on, :lyrics] > end > end > > def create_song > begin > @song = Song.create(params[:song]) > rescue > flash[:notice] = @song.errors.full_messages > end > end > end > > get '/new' do > protected! > @song = Song.new > slim :new_song > end > > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
