Make The Form Work
Goals
Steps
Step 1: Try to submit form
Error! Woo!!!
The action 'create' could not be found for JobsController
Step 2: add the action create to the JobsController
def create endStep 3: debug your app using the server output
Discussion: Logging & Server Output
Error! Woo!!!
No template found for JobsController#create, rendering head :no_content
Step 4: redirect back to jobs
def create redirect_to jobs_path endStep 5: save the form data
Parameters: { "authenticity_token"=>"[FILTERED]", "job"=>{ "title"=>"organizer organizer", "description"=>"We need an someone to organize the organizers." }, "commit"=>"Create Job" }def create Job.create(job_params) redirect_to jobs_path end private def job_params params.require(:job).permit(:title, :description) endStep 6: find the jobs on the rails console
Rails console time! Open up another tab or window in your terminal and type this:rails cAfter that's loaded, let's see how many jobs we've saved to the database:Job.count
def create p "In the create method!!!!!!" job = Job.create(job_params) p job redirect_to jobs_path end
Now would be a good time to commit to git
Next Step:
Go on to CRUD And Resourceful Routing