Hack hack hack...

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

HAW-day7

Goals: add text field to all tags index page figure out why fix button doesn’t work on errors index and why none work on show pages

Way to call a method in the view:

action in the controller a route that maps to the to the controller and action can i just not call <% import %> or something? ajax can ping errors/import

progress bars for import are in the

flash message: In the helpers/application_helper.rb

in the layouts/application.html.erb

Refresh Errors
1
<a class="btn btn-success" <%=link_to "Refresh Errors", errors_import_path%></a>

We put the link_to inside the a class. But it seems to that the A tag is open

Adding flash messages
1
2
3
4
5
6
7
8
  def flash_class(level)
    case level
      when :notice then 'info'
      when :error then 'error'
      when :alert then 'warning'
    end
  end
end

delayed job - backend server if it takes a variable it uses a colon and needs are parameter… pop up and alert box

Button:
1
2
<a class="btn btn-success" <%= link_to "Refresh Errors", "errors_import_path" %></a>
#this is the path that is the abstraction of the path in rakeroutes

attr_accessbile is ignored in mongoid

document in the the view we added

LESSONS: In the controller I was calling trying to find the Tag by ID. The correct way is below…

1
@tag = Tag.find_by_slug params[:id]

Routes

We always need a route when we are calling an action… So if there is a dynamic variable (like ID– always indicated with a colon) in the route, it needs a paramater passed in!

DO NOT Hardcode, use the alias name. Sometimes this means that you need to name it

Use the :as to name the route path
1
2
match 'errors/:id/tag_general' => 'errors#tag_general', :as => 'tag_general_error'
#now this can be referred to as the tag_general_error_path
adding images to octopress
1
{% img http://claudiolassala.files.wordpress.com/2011/05/routes.png %}

redrirect_to :back brings you back to the original page. This was useful for destroying a tag name and then redirecting to the tag index.

Comments