This file contains hidden or 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
class CommentsController < ApplicationController | |
def index | |
@commentable = Video.find(params[:video_id]) | |
@comments = @commentable.comments | |
end | |
def new | |
@commentable = Video.find(params[:video_id]) | |
@comment = @commentable.comments.new | |
end |
This file contains hidden or 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
#course_helper | |
def coursenames(courseid) | |
@coursedept = Department.all(:include => :courses, :conditions => ["courses.id = ?",courseid]) | |
@coursedept.map(&:name) | |
end | |
<% @course.each do |course| %> | |
<tr> | |
<td><%= course.code %></td> |
This file contains hidden or 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
<%= link_to path_helper_goes_here, :class => "decideBtn" do %> | |
<i class="icon-plus icon-white"></i> | |
Add | |
<% end %> |
This file contains hidden or 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
activerecord: | |
errors: | |
models: | |
user: | |
errors: &errors | |
blank: campo obrigatório | |
attributes: | |
name: *errors | |
email: *errors |
This file contains hidden or 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
class Friendship < ActiveRecord::Base | |
attr_accessible :friend_id, :user_id, :status | |
belongs_to :user | |
belongs_to :friend, :class_name => 'User', :counter_cache => :friends_count | |
def self.request(user, friend) | |
unless user == friend or Friendship.where(:user_id => user, :friend_id => friend).exists? | |
transaction do | |
create({:user => user, :friend => friend, :status => 'pending'}, :without_protection => true) | |
create({:user => friend, :friend => user, :status => 'requested'}, :without_protection => true) |
This file contains hidden or 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
class Page < ActiveRecord::Base | |
belongs_to :book | |
attr_accessible :link, :summary, :title | |
before_save :set_title | |
scope :title, where("title is not null") | |
def set_title | |
self.title ||= URI.parse(link).host | |
end | |
end |
This file contains hidden or 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
class BackgroundJobChecker | |
def self.check | |
Resque::Plugins::Status::Hash.statuses.each do |job| | |
return !job.working? | |
end | |
end | |
end |
This file contains hidden or 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
<% @hospitals.each do |hospital| %> | |
<% hospital.hospital_bookings.each do |booking| %> |
This file contains hidden or 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
describe 'on signup page' do | |
before { visit '/signup' } | |
context "with invalid information" do | |
# tests here work great | |
end | |
context 'with valid information' do |
This file contains hidden or 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
class Discount < ActiveRecord::Base | |
def unused | |
self.orders. | |
where(:state => ['shipped', 'paid', 'completed', 'processing']). | |
where(:user_id => user.id). | |
count | |
end | |
end | |