-
The new rake task assets:clean removes precompiled assets. [fxn]
-
Application and plugin generation run bundle install unless
--skip-gemfile
or--skip-bundle
. [fxn] -
Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]
-
Template generation for jdbcpostgresql #jruby [Vishnu Atrai]
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
class Post < ActiveRecord::Base | |
attr_accessor :comment # fake attribute used for spam trapping | |
validates_length_of :comment, :in => 0..1 | |
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
Hotel.populate 2..5 do |hostel| | |
hotel.city_id = city.id | |
hotel.name = Populator.words(1..2) + " hotel" | |
hotel.phone = Faker::PhoneNumber.phone_number | |
hotel.address = Faker::Address.street_address | |
Event.populate 4...8 do |event| | |
event.date_and_time = 3.days.from_now...10.months.from_now | |
event.title = Populator.words(2..5).titleize | |
ActiveRecord::Base.connection.execute("INSERT INTO events_hotels (event_id, | |
hotel_id) VALUES (#{event.id}, #{hotel.id})") |
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
Factory.define :item do |f| | |
include ActionDispatch::TestProcess | |
f.name "Macbook Pro 15" | |
f.price_in_dollars 1500 | |
f.photo fixture_file_upload('/files/avatar.jpg', 'image/jpg') | |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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
# This is a contrived example. | |
# But, this simple example demonstrates some code I have seen where not understanding the difference | |
# between 'and' and '&&' has caused unexpected behavior. | |
# The intent is to evaluate the 3rd clause if the 1st and 2nd clause is true. | |
# Again, this is a contrived example. | |
# But, imagine that the 1st and 2nd clause is a method invocation or something like that. | |
# This is a classic example where the goal of terseness really caused problems. | |
>> x = 10 && y = 5 && x - y |
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
module NullifyBlankAttributes | |
def write_attribute(attr_name, value) | |
new_value = value.presence | |
super(attr_name, new_value) | |
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
require 'rubygems' | |
require 'spork' | |
Spork.prefork do | |
ENV["RAILS_ENV"] ||= "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
...cucumber and capybara requires... | |
require 'database_cleaner' |
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
module ApplicationHelper | |
def private_cache (name = {}, &block) | |
if @user.blank? | |
yield and return #note.. I had to add this return..otherwise it rendered twice | |
else | |
cache(name, &block) | |
end | |
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
connection = Faraday::Connection.new('http://example.com') do |builder| | |
builder.request :url_encoded # for POST/PUT params | |
builder.adapter :net_http | |
end | |
# same as above, short form: | |
connection = Faraday.new 'http://example.com' | |
# GET | |
connection.get '/posts' |
OlderNewer