Stack Exchange
Categories not working in production at heroku Rails 4
I am new to rails and still learning my application's Category function works in development but not in production at Heroku any help much appreciated.
In my pins_controller.rb
def index
    if params[:category].blank?
      @pins = Pin.all.order("created_at DESC").paginate(page: params[:page], per_page: 50)
    else
      @category_id = Category.find_by(name: params[:category]).id
      @pins = Pin.where(category_id: @category_id).order("created_at DESC").paginate(page: params[:page], per_page: 20)
    end 
  end

Associations have been made between models category.rb and pin.rb
Categories were created using 'Rails console’
I added a drop-down to nav-bar with 16 Categories here is the code,
_header.html.erb

<li class="dropdown">
  <a href="#" class="dropdown-toggle" data-toggle="dropdown"><span class="fa fa-th"></span> Categories<b class="caret"></b></a>
  <ul class="dropdown-menu">
    <% Category.all.each do |category| %>
      <li><%= link_to category.name, pins_path(category: category.name) %></li>
    <% end %>
  </ul>
</li>

_form.html.erb
<div class="form-group">
    <%= f.collection_select :category_id, Category.all, :id, :name, {prompt: "Select category"} %>
  </div>


What do you mean by "doesn't work"?

You added categories to your live system via rails console?

This was my first question and it seems i mucked it up im not sure how to include my code .. the question is how do i get Categories working on heroku ?

My applications categories function in development but not in production at Heroku visit it at webrip.tv

Yes using Category.create(name: "Action") in rails console

try to run heroku rake db:migrate

Here is the index url https://thawing-brushlands-6780.herokuapp.com/

I have tried heroku pg:reset DATABASE to dump the db
heroku rake db:migrate RAILS_ENV=production to create and migrate db at heroku (no errors)
heroku restart to restart dyno

Visit the app and sign in using Name: MrAwesome
Email: hey@mac.com
Pass: Railsapp

Then try create a new movie. Category select box does not function at all

What about my environments/production.rb file ? could my issue be in there..

On my index page i just compared development and production environments with the inspector. Development outputs <ul class="dropdown-menu> if opened lists all categories in  tags.If i do the same with production all the 's are missing ? where is the output ? the code seems to be in version control at Github it seems to not be at Heroku ??? i am lost...

This issue has been resolved, silly me just had to re-create Categories in production at Heroku as follows: $ Heroku run rails console to start console in production, then $ Category.connection to establish a connection, and then it's time to create categories with Category.create(name: "Action") etc etc. All is working ! Big thanks to MackenzieChild at unicasts.com

Thanks to everybody that made a suggestion.

Big thank you to Taryn East your awesome. I revised comment 2 and see my issue has actually been solved with Taryn's question provided. I will be sure to give closer consideration to her comments in the future, Thank's Taryn East. .Michael

This issue has been resolved, silly me just had to re-create Categories in production at Heroku as follows: $ Heroku run rails console to start console in production, then $ Category.connection to establish a connection, and then it's time to create categories with Category.create(name: "Action") etc etc. All is working ! Big thanks to MackenzieChild at unicasts.com 
