Skip to content

Instantly share code, notes, and snippets.

View sameera207's full-sized avatar

Sameera (Sam) sameera207

  • Sydney
View GitHub Profile
context 'buyer names changes' do
let(:name) { 'Lindt' }
let(:supplier) { Supplier.create(name: 'Cocoa Beans Inc', email: 'cb@gmail.com', password: 'password') }
let(:buyer) { Buyer.cretae(name: name, email: 'lindt@gmail.com', password: 'password') }
subject {
FactoryGirl.create(:trade_request, buyer: buyer, supplier: supplier)
}
# go for a logical context name
@sameera207
sameera207 / 0_reuse_code.js
Created April 29, 2016 03:46
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
class Admin::GroupsController < Admin::BaseController
def delete_all_groups
GroupService.new(current_user, @group).delete_all_groups
end
end
class GroupService
def initialize(user, group)
@user = user
@group = group
class FeaturedPhotosService
def self.clean_featured_photo_for(listing_photo)
updated_record_count = Listing.where(featured_photo_id: listing_photo.id).
update_all(featured_photo_id: nil)
listing_photo.destroy if updated_record_count > 0
end
end
<% @settings['sites'].keys.sort.each do |sitename| %>
<% sitename[sitename].keys.delete_if { |key, val| key != 'path_map' }.sort.each do |siteatt|
<% siteatt.keys.sort.each do |sitemap| %>
backend backend_<% sitename %>_<%= sitemap %>
<% end %>
<% end %>
<% end -%>
context "Description" do
before(:each) do
group
end
context "is less than 25 characters" do
context "without line breaks" do
before(:each) { row[:Description] = "123456789012345678901234" }
it { is_expected.to be false }
end
context "with line breaks" do
context "Description" do
before(:each) do
group
end
context "is less than 25 characters" do
context "without line breaks" do
before(:each) { row[:Description] = "123456789012345678901234" }
it { is_expected.to be false }
end
context "with line breaks" do
@sameera207
sameera207 / gist:4cf93cb65970eac6f92c
Created March 3, 2015 09:33
Using Custom URL Schemes In Your Ionic Framework App
// link <a title="recipe" href="sampleapp://recipes/3">recipe</a>
//app.js
function handleOpenURL(url) {
setTimeout(function() {
window.location.hash = '/app/show/' + url.split("/").pop();
}, 500);
}
// following is my router
@sameera207
sameera207 / accept nested attributes with rails4
Created October 13, 2014 02:40
accept nested attributes with rails4 strong params
class ItemsController < ApplicationController
#rest of your methods
# ......
private
def item_params
params.require(:item).permit(
:name,
:content,
:image,
:address,
=== Rails migrations ===
In ruby/rails projects , the standard way of hadling database changes (add/edit tables, add/edit columns etc..)
through the migrations. this way we can hadle database changes easily.
=== where are the migrations ===
migrations are in the following folder
```ruby