Reputation: 6068
When submitting a form (title and content that should pass), I get the following:
Next, in events.rb, I commented out the validation requirements:
class Event < ActiveRecord::Base
has_many :comments, dependent: :destroy
#validates :title, presence: true,
# length: { minimum: 5 }
end
After that, the form would let me submit an event post, but everything was blank, as shown:
As a note, my submissions were working until around the time I submitted Devise, and made a few other changes with adding a user model. Please take a look and let me know what I can do about this.
Upvotes: 0
Views: 53
Reputation: 53028
Looking at your EventsController in git repo, I see that in your create action you are creating the event instance as follows:
@event = Event.new(params[:event].permit(:title, :text))
Change that to
@event = Event.new(event_params)
Or
@event = Event.new(params.require(:event).permit(:title, :text))
you can check it by turning on the validations, It should work now.
Upvotes: 0
Reputation: 8006
In your events_controller.rb
, you need to permit the desired user-editable parameters, and create your event with that.
Event.create!(event_params)
def event_params
params.require(:event).permit(:title, :description)
end
Upvotes: 1
Reputation: 2121
If you don't want it to be blank, then you will still need
validates :title, presence: true
Upvotes: 0