title: Ruby: Begin transaction, rollback transaction
body: <p>New in rubies, I'm facing a tiny problem.. need a fresh pair of eyes</p>
  
  <p>fyi: I'm not using scaffold so that I can understand the step by step process of building in ruby.</p>
  
  <p>When I try to add a new gig, it does not save on the database and I see the following error on my server logs...</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Started POST "/gigs" for ::1 at 2017-03-06 17:34:34 +0300
  Processing by GigsController#create as HTML
    Parameters: {"utf8"=&gt;"✓", "authenticity_token"=&gt;"lDSSVGuQDFlKwdkP8m1Gk4rzA4wG03wzpd5LmA19HZM7LPOLSrDBYGSsRRvwRZTbfVoe/HZmeGxBjRwVnZSKBw==", "gig"=&gt;{"name"=&gt;"Perry Dillard", "budget"=&gt;"500", "duration"=&gt;"4", "startdate"=&gt;"19-Jan-1971", "description"=&gt;"Reprehenderit, eligendi natus consequatur, dicta quae corporis voluptatem, ut pariatur. Consequatur excepteur natus eos, eos cum et eiusmod.", "location"=&gt;"Dicta beatae culpa ut nostrud nihil voluptatem Eum", "open"=&gt;"true", "hired"=&gt;"1"}, "commit"=&gt;"post it"}
     (0.1ms)  begin transaction
     (0.1ms)  rollback transaction
  Redirected to http://localhost:3000/gigs
  Completed 302 Found in 3ms (ActiveRecord: 0.1ms)
  
  
  Started GET "/gigs" for ::1 at 2017-03-06 17:34:34 +0300
  Processing by GigsController#index as HTML
    Rendering gigs/index.html.erb within layouts/application
    Rendered gigs/index.html.erb within layouts/application (0.6ms)
    User Load (0.2ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT ?  [["id", 1], ["LIMIT", 1]]
    Rendered layouts/_nav.html.erb (1.6ms)
  Completed 200 OK in 29ms (Views: 26.7ms | ActiveRecord: 0.2ms)</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my form</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div class="container"&gt;
   &lt;h4 class ="center"&gt;Post an Internship Opportunity&lt;/h4&gt;
   &lt;br&gt;
      &lt;div class="col-sm-8"&gt;
  &lt;%= form_for @gig do |f| %&gt;
      
       &lt;div class= "row"&gt; 
        &lt;div class="col-sm-10"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :name %&gt;
          &lt;%= f.text_field :name, autofocus: true, class: "form-control input-lg" %&gt;
          &lt;small class="healer block"&gt; Data entry, writer, receptinist etc &lt;/small&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt; 
  
        &lt;div class="col-sm-3"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :budget %&gt;
          &lt;%= f.text_field :budget, class: "form-control" %&gt;
          &lt;small class="healer block"&gt; Free or min Kshs 5000 &lt;/small&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-4"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :duration %&gt;
          &lt;%= f.text_field :duration, class: "form-control" %&gt;
          &lt;small class="healer block"&gt; 2 weeks, 1 month, 3 months &lt;/small&gt;
         &lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-3"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :startdate %&gt;
          &lt;%= f.text_field :startdate, class: "form-control" %&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-10"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :description %&gt;
          &lt;%= f.text_area :description, class: "form-control" %&gt;
          &lt;small class="healer block"&gt; What are the expectations and working hours, mentorship opportunities etc &lt;/small&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-10"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :location %&gt;
          &lt;%= f.text_field :location, class: "form-control " %&gt;
          &lt;small class="healer block"&gt; ignore if same location with your registered office &lt;/small&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
  
        &lt;div class="col-sm-5"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :open %&gt;
          &lt;%= f.text_field :open, class: "form-control" %&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-5"&gt;
         &lt;div class="form-group"&gt;
          &lt;%= f.label :hired %&gt;
          &lt;%= f.text_field :hired, class: "form-control" %&gt;
         &lt;/div&gt;&lt;!-- /.form-group --&gt;
        &lt;/div&gt;
        &lt;div class="col-sm-10"&gt;
       &lt;div class="form-group"&gt;
               &lt;button type="submit" class="btn btn-secondary btn-block"&gt;   &lt;%= f.submit "post it" %&gt; &lt;/button&gt;
              &lt;/div&gt;
          &lt;/div&gt;
    &lt;/div&gt;
    &lt;% end %&gt;
      &lt;/div&gt;&lt;!-- /.col-* --&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>This is my gig controller</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class GigsController &lt; ApplicationController
  
   def index
    
   end
  
   def new
    @gig = Gig.new 
   end
  
   def create
    @gig = Gig.new(gig_params)
    @gig.save
    redirect_to @gig
   end
  
   
  #private stuff
   private
  
   def gig_params
    params.require(:gig).permit(:name, :description, :budget, :startdate, :duration, :location, :open, :hired )
   end
  
  
  end</code></pre>
  </div>
  </div>
  </p>
  
  <p>Feel it might help if I add my schema?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>  create_table "gigs", force: :cascade do |t|
      t.string   "name"
      t.text     "description"
      t.integer  "budget"
      t.date     "startdate"
      t.integer  "duration"
      t.string   "location"
      t.boolean  "open",        default: true
      t.integer  "hired"
      t.datetime "created_at",                 null: false
      t.datetime "updated_at",                 null: false
      t.integer  "category_id"
      t.integer  "user_id"
      t.index ["category_id"], name: "index_gigs_on_category_id"
      t.index ["user_id"], name: "index_gigs_on_user_id"
    end</code></pre>
  </div>
  </div>
  </p>
  
  <p>Adding Gig model as well</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>class Gig &lt; ActiveRecord::Base
   has_many :proposals
   belongs_to :user
   belongs_to  :category
   has_many :abilities
   has_many :skills, through: :abilities
  end</code></pre>
  </div>
  </div>
  </p>