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
#models | |
class Link < ActiveRecord::Base | |
has_many :link_urls | |
accepts_nested_attributes_for :link_urls, :allow_destroy => true #, :reject_if => lambda { |a| a[:url].blank? } | |
end | |
class LinkUrl < ActiveRecord::Base | |
belongs_to :link | |
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
# in controller method | |
@user = User.find_by_email(params[:email]) | |
if @user.nil? | |
flash.now[:error] = 'No user found by that email address' | |
end | |
# view (in haml) | |
- unless flash.nil? | |
- if flash[:notice] |
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
# SQLite version 3.x | |
# gem install sqlite3 | |
development: | |
adapter: sqlite3 | |
database: db/development.sqlite3 | |
pool: 5 | |
timeout: 5000 | |
production: | |
adapter: mysql |
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
# flash partial | |
- flash.each do |type,value| | |
- unless value.nil? | |
%div{:class => type.to_s} | |
%div | |
%span | |
= value | |
- unless object.nil? | |
%ul | |
- object.errors.full_messages.each do |msg| |
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
conditions = {} | |
conditions[:title.matches] = '%'+@search_value+'%' | |
conditions[:description.matches] = '%'+@search_value+'%' | |
conditions[:status] = params[:show] if params[:show] != 'all' |
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
conditions = {} | |
conditions.merge({:first_name.matches => '%'+@search_value+'%'} | {:last_name.matches => '%'+@search_value+'%'}) unless @search_value.blank? |
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 "spec_helper" | |
describe UserMailer do | |
describe "registration_email" do | |
@user = mock_model(User, :email => '[email protected]', :first_name => 'john') | |
let(:mail) { UserMailer.registration_email(@user) } | |
it "renders the headers" do | |
mail.subject.should eq("Welcome to ScreenZone!") |
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
validates :password_confirmation, :presence => true, :if => Proc.new { |u| !u.password.blank? && u.password_confirmation.present? } |
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
# PRODUCT MODEL | |
has_many :product_people | |
has_many :people, :through => :product_people | |
accepts_nested_attributes_for :people | |
# PRODUCTS IN ACTIVE ADMIN | |
f.inputs "Cast" do | |
f.has_many :product_people do |p| | |
p.input :name |
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
/** | |
* Paginator | |
* | |
* The paginator can be used within any controller to easily set up | |
* some pagination options, including number of pages, page navigation | |
* and more. It is built to work with Laravel's own pagination library, | |
* which returns data in a particular format. | |
* | |
* Usage: | |
* Before you can use paginator, make sure you specify the URLs to your pagination |
OlderNewer