Hack hack hack...

An open journal-- some of it written for you, but most of it is for me.

Haw-day1

Deploying to Heroku

Make sure to modify the mongoid.yml file to config the production environment.

2 major issues with the mongoid deploy:

  1. Issue with ruby version was the first error we encountered… need to keep in that mongoid only supports 1.9.3 this ended up being a big issue.

In –> heroku logs –tail:

1
2
3
4
5
ActionView::Template::Error (undefined method `[]' for nil:NilClass):
 11:   </thead>
 10:     </tr>
 12: 
 13:   <% @airbrake_errors.each_with_index do |a_e, index| %>
  1. The other issue was to reconfigure the setting below from false to true as the
config/environments/production.rb
1
 config.assets.compile = true
config/environments/production.rb
1
2
3
4
5
 ActionView::Template::Error (images/apple-touch-icon-144x144-precomposed.png isn't precompiled):

 <%= favicon_link_tag 'images/apple-touch-icon-144x144-precomposed.png', :rel => 'apple-touch-icon-precomposed', :type => 'image/png', :sizes => '144x144' %>

 app/views/layouts/application.html.erb:19:in `_app_views_layouts_application_html_erb___1957659516384225917_21931620'

Rewriting the writer

Change the tag writer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
def tag_names=(string_of_names)
    string_of_names.split(", ").each do |tag_name|
      self.tags.find_or_create_by(name: tag_name)
      #the find_or_create_by wasn't creating unique tag names
      #the reason was because we were linking too many methods together
      #mongoid is finicky
    end
  end

# was changed to...
def tag_names=(string_of_names)
    self.tags << string_of_names.split(", ").collect do |tag_name|
      tag = Tag.find_or_create_by(name: tag_name)
    end
  end

# but we discoved that the tags were no disappearing if they were left off the form
def tag_names=(string_of_names)
   #later we added this line because tags were persisting even if we tried to edit them.
    self.tags.delete_all
    self.tags << string_of_names.split(", ").collect do |tag_name|
      tag = Tag.find_or_create_by(name: tag_name)
    end
  end
the last td was changed…
1
2
3
4
5
6
7
8
 <% @airbrake_errors.each_with_index do |a_e, index| %>
    <tr>
      <td>
      <%= a_e.tags.collect{ |tag|
         link_to(tag.name, tag_path(tag)) #=> "<a href="adasda">Tag</a>"
      }.join(", ").html_safe %>
     </td>
      # this needs to be better understood-- TODO

HTTP Authentication

Pushing the seed file to heroku

the last td was changed…
1
 heroku run rake db:seed

Comments