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 what my params looks like | |
{:group_id=>86, | |
:payer_id=>1982, | |
:account_type=>"standard", | |
:sms_credit_price_ex_tax=>"0.025", | |
:auto_purchase_sms_credits_amount=>1000, | |
:setup_invoice=>true, | |
:locale=>"en-GB", | |
:timezone=>"London", |
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
describe 'DELETE #destroy' do | |
let(:dummy) { mock('Dummy') } | |
it "should find the object with the given ID and destroy it" do | |
# set the expectations about the interactions | |
Dummy.should_receive(:find).with(99).and_return dummy | |
dummy.should_receive(:destroy) | |
delete :destroy, id: 99 | |
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
<%= simple_form_for @item do |i| %> | |
<%= i.input :name %> | |
<%= i.input :description %> | |
<%= i.input :price %> | |
<%= i.input :zip %> | |
<%= i.input :weight %> | |
<%= i.input :volume %> | |
<%= i.simple_fields_for :item_images do |image| %> | |
<% image.input :image, as: :file %> | |
<% 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 self.create_from_parent(parent_type, parent_id, comment_params, current_account) | |
parent = parent_type.safe_constantize | |
raise ActiveRecord::RecordNotFound unless parent && (parent.reflect_on_association(:comments).klass == self) | |
parent.find(parent_id).comments.create(comment_params.merge(account: current_account)) | |
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
sudo apt-get --force-yes install build-essential openssl libreadline6 libreadline6-dev curl \ | |
zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev \ | |
libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison | |
&& | |
\curl -L https://get.rvm.io | bash -s stable --autolibs=enabled | |
&& | |
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 self.find_by_id_or_first(id) | |
(id && where(:id => id).first) || first | |
end | |
# or... | |
def self.find_by_id_or_first(id) | |
order("id = #{id.to_i} DESC").first | |
end |