This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Trying to figure out why Report.all returns this: | |
irb(main):006:0> a = Report.all | |
=> [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Within the user model | |
... | |
#READONLY! Sets all of the user tokens to read-only. | |
def readonly! | |
self.tokens.each do |t| | |
t.capabilities = [:list,:view,:search] | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index | |
#... | |
current_page = (params[:page] || 1) # <--- I probably should just 'to_i' both current_page and per_page | |
per_page = (params[:per_page] || 25) # <--- | |
#... | |
@reports = WillPaginate::Collection.create(current_page, per_page, @results.count) do |pager| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% for audit in @audits %> | |
<tr> | |
<%if audit.user.present? #<--- Guard against nil users.%> | |
<td><%= link_to(audit.user.to_label, url_for(audit.user)) %></td> | |
<%else #<--- Present "Missing" on nil user.%> | |
<td>Missing</td> | |
<%end%> | |
<td><%= audit.kind %></td> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Where the associations table has sourcable_id,sourcable_type,targetable_id,targetable_type | |
class Association < ActiveRecord::Base | |
include Relatable | |
belongs_to_association :sourcable => :sourcable, :targetable => :targetable | |
end | |
#OR _any_ table that we want to be an association table can become one (if the source and target id and type columns do not exist, then the mixin creates them) | |
class AssociationTables < ActiveRecord::Base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#like this ... | |
<p> | |
<b>Notes:</b> | |
<% if @sighting.notes.nil? %> | |
<span id="notes"> </span> | |
<% else %> | |
<span id="notes"><%= @sighting.notes %></span> | |
<% end %> | |
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alert('foo'); |