Skip to content

Instantly share code, notes, and snippets.

View biagidp's full-sized avatar

David Biagi biagidp

View GitHub Profile
source 'https://rubygems.org'
gem 'rails', '3.2.14'
gem 'pg'
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'therubyracer', :platforms => :ruby
gem 'uglifier', '>= 1.0.3'
gem 'less-rails'
NoMethodError in Spree/admin/stock_locations#index
Showing /home/david/.rvm/gems/ruby-1.9.3-p392/bundler/gems/spree-fea90fb7fb24/backend/app/views/spree/admin/stock_locations/index.html.erb where line #40 raised:
undefined method `admin_name' for #<Spree::StockLocation:0x007fe7846c1178>
Extracted source (around line #40):
37: @delete_url = admin_stock_location_path(stock_location)
38: %>
39: <tr id="<%= spree_dom_id stock_location %>" data-hook="stock_location_row" class="<%= cycle('odd', 'even')%>">
<div id="prior_cancer_history">
<% @medical_family_history.prior_cancer_histories.each_with_index do |prior_cancer_history, i| %>
<%= f.fields_for :prior_cancer_histories, prior_cancer_history do |f| %>
<%= javascript_tag(build_row(render_to_string('prior_cancer_history_fields', :f => f, :i => i), i)) %>
<% end %>
<% end %>
</div>
@biagidp
biagidp / gist:1507541
Created December 21, 2011 20:23
class_eval implementation
require 'active_record'
module SaveAsDraft
ActiveRecord::Base.class_eval do
alias_method :save_without_draft, :save
def save_with_draft
if self.has_attribute?(:record_status) and self.record_status == "Draft"
save_without_draft(:validate => false)
else
@biagidp
biagidp / save_as_draft.rb
Created December 21, 2011 18:10
lib/save_as_draft for rails 3.0
class ActiveRecord::Base
module SaveAsDraft
def save
if self.has_attribute?(:record_status) and self.record_status == "Draft"
super(:validate => false)
else
super
end
end
end
@biagidp
biagidp / save_as_draft.rb
Created December 21, 2011 18:10
lib/save_as_draft for rails 3.0
class ActiveRecord::Base
module SaveAsDraft
def save
if self.has_attribute?(:record_status) and self.record_status == "Draft"
super(:validate => false)
else
super
end
end
end
Dev:
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Helpers::FormTagHelper!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Helpers::FormHelper!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Helpers::InstanceTag!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Helpers!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Base!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Base!
ActionView::Helpers::UrlHelper WAS INCLUDED IN ActionView::Base!
Development:
[HomePagesController, ApplicationController, UrlHelper, ActionController::Base, Devise::Controllers::Helpers, TinyMCE::Base, TinyMCE::SpellChecker, #<Module:0x00000001eb2278>, ActionDispatch::Routing::Helpers, #<Module:0x00000002ac2950>, ActiveRecord::Railties::ControllerRuntime, Devise::Controllers::UrlHelpers, ActionController::Compatibility, ActionController::Rescue, ActiveSupport::Rescuable, ActionController::Instrumentation, ActionController::HttpAuthentication::Token::ControllerMethods, ActionController::HttpAuthentication::Digest::ControllerMethods, ActionController::HttpAuthentication::Basic::ControllerMethods, ActionController::RecordIdentifier, ActionController::Streaming, ActionController::RequestForgeryProtection, AbstractController::Callbacks, ActiveSupport::Callbacks, ActionController::Flash, ActionController::Cookies, ActionController::ImplicitRender, ActionController::MimeResponds, ActionController::Caching, ActionController::Caching::Fragments, ActionController::Caching::Config
@biagidp
biagidp / gist:885485
Created March 24, 2011 17:33
Jquery getJSON
$(document).ready(function(){
$('.init').click(function(event){
$.getJSON("http://localhost:37280/sites/1/encode?callback=?", { key: $("#target").attr('value') }, function(data){
alert(data);
});
event.preventDefault();
});
});
ActionController::Routing::Routes.draw do |map|
map.resources :user_sessions
map.resources :sites, :users
map.resources :sites, :member => { :encode => :get, :decode => :get }
map.login "login", :controller => "user_sessions", :action => "new"
map.logout "logout", :controller => "user_sessions", :action => "destroy"
map.root :login