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 Inspiration < Feedback | |
belongs_to :user | |
belongs_to :group | |
belongs_to :inspired_group, :class_name => "Group", :foreign_key => "inspired_group_id" | |
#Will Paginate | |
cattr_reader :per_page | |
@@per_page = 10 | |
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 SearchController < ApplicationController | |
def index | |
case params[:show] | |
when 'people' | |
search_scope = [User] | |
when 'projects' | |
search_scope = [Project] | |
else | |
search_scope = [User, Project] | |
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 SearchesController < ApplicationController | |
def show | |
@search = Post.search do | |
if params[:q].present? | |
keywords(params[:q]) do | |
highlight :body | |
end | |
end | |
if params[:cat].present? | |
with(:category_id, params[:cat].to_i) |
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 "named scope" do | |
describe "#similar_to" do | |
let(:category) { Factory.create(:category) } | |
let(:product) { | |
Factory.create( | |
:product, :categories => [category] | |
) |
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
require "webrat/core/save_and_open_page" | |
require "webrat/selenium/selenium_rc_server" | |
require "webrat/selenium/application_server_factory" | |
require "webrat/selenium/application_servers/base" | |
require "selenium" | |
module Webrat | |
class TimeoutError < WebratError | |
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
def construct_sql | |
case | |
when @reflection.options[:finder_sql] | |
@finder_sql = interpolate_sql(@reflection.options[:finder_sql]) | |
when @reflection.options[:as] | |
@finder_sql = | |
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_id = #{owner_quoted_id} AND " + | |
"#{@reflection.quoted_table_name}.#{@reflection.options[:as]}_type = #{@owner.class.quote_value(@owner.class.base_class.name.to_s)}" | |
@finder_sql << " AND (#{conditions})" if conditions |
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 Game < ActiveRecord::Base | |
include ProductsStateMachine | |
include ProductsRating | |
include Commentable | |
include GamesAndMusicMethods | |
include VideoAttachable | |
belongs_to :company | |
belongs_to :genre | |
has_many :game_files, :dependent => :destroy, :validate => true, :autosave => true | |
has_many :activation_codes |
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
def current_user(author = false) | |
# Create new test user | |
unless @current_user | |
user = Factory.create(:user) | |
if author | |
Factory.create(:contributor, :user => user) | |
end | |
@current_user = User.find(user.id) | |
end | |
@current_user |
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
after_update do |m| | |
m.album.update_attribute(:band_id, m.band_id) if m.album.is_a?(Single) && m.band_id_changed? | |
if m.audio_id_changed? && m.audio_id.present? # audio => audio | |
audio = Audio.find( m.old_audio_id ) | |
if audio.is_a?( Single ) # single => album | |
audio.destroy | |
end | |
end | |
true | |
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 RenameAlbumsToAudios < ActiveRecord::Migration | |
def self.up | |
rename_table :albums, :audios | |
end | |
def self.down | |
rename_table :audios, :albums | |
end | |
end |
OlderNewer