Skip to content

Instantly share code, notes, and snippets.

View imustardsoft's full-sized avatar

iMustardSoft imustardsoft

View GitHub Profile
class Def
def method1
end
end
Our corporate website, www.imustardsoft.com is based on "Radiant CMS":http://radiantcms.org, a no-fluff, open source content management system designed for small teams. We love Radiant. Yes, I know, we are biased because it is based on Ruby on Rails, iMustardsoft's specialty technology. Radiant has many nice features:
1. An elegant user interface
2. A first-class extension/plugin system
3. Simple user management and permissions
4. Flexible templating with layouts, snippets, page parts, and a custom tagging language.
p. One of the most important functions in our website is Blog. Even though Radiant provides blog (articles) out of the box, it wasn't exactly what we needed. We want our team members to be able to post articles and don't interfere each other. After trying out existing extensions, we decided to develop our own blog engine to achieve it. Thus, a new blog extension is born @ "http://github.com/imustardsoft/Radiant-blog":http://github.com/imustardsoft/Radiant-blog.
This extension add a new user ro
event=request_started verb=POST path=/users/invitation ip=127.0.0.1
Redirected to http://localhost:3000/users/invitation/new
event=request_completed status=302 controller=InvitationsController action=create format=HTML ms=23 params='{"commit"=>"Send an invitation", "authenticity_token"=>"5irMWlpNPaDwBeL4dfR1IrIrDlIZtN+JgD6QxL6KP7Y=", "utf8"=>"✓", "user"=>{"invite_messages"=>"[FILTERED]", "aspects"=>"4d43749c8ff95314ae00000e", "email"=>"xingxingyuanyan@163.com"}}' r_id=46749f033c11891c7603
event=request_started verb=GET path=/users/invitation/new ip=127.0.0.1
event=render template=js/_websocket_js.haml ms=1.6
event=render template=aspects/_new_aspect.haml ms=6.3
event=render template=layouts/_header.html.haml ms=23.9
event=render template=invitations/new.html.haml layout=layouts/application ms=170.6
event=request_completed status=200 controller=InvitationsController action=new format=HTML ms=560 r_id=46749f033c11891c7603
event=socket-subscribe uid=4d43743e8ff95314ae000004 channels=0
set :gateway, 'YOUR GATEWAY SERVER IP'
role :web, "web1", "web2"
@imustardsoft
imustardsoft / form_tag_helper.rb
Created October 13, 2011 20:11
actionpack-3.0.6/lib/action_view/helpers/form_tag_helper.rb
def select_tag(name, option_tags = nil, options = {})
if Array === option_tags
ActiveSupport::Deprecation.warn 'Passing an array of option_tags to select_tag implicitly joins them without marking them as HTML-safe. Pass option_tags.join.html_safe instead.', caller
end
html_name = (options[:multiple] == true && !name.to_s.ends_with?("[]")) ? "#{name}[]" : name
if blank = options.delete(:include_blank)
if blank.kind_of?(String)
option_tags = "<option value=\"\">#{blank}</option>".html_safe + option_tags
else
@imustardsoft
imustardsoft / rails select tag
Created October 15, 2011 15:27
examples from rails doc
select_tag "people", options_from_collection_for_select(@people, "id", "name"), :prompt => "Select something"
# => <select id="people" name="people"><option value="">Select something</option><option value="1">David</option></select>
@imustardsoft
imustardsoft / gist:1347631
Created November 8, 2011 12:28
spree error msg
ActionView::Template::Error (undefined method `to_d' for #<Order:0x82cce98>):
14: <h3>Shipping Method:</h3>
15: <div class="method">
16: <% i = 1 %>
17: <% @order.rate_hash.each do |shipping_method| %>
18: <%= radio_button(:order, :shipping_method_id, shipping_method[:id], :class => "radio#{i}", :id => shipping_method[:cost]) %>
19: <label><%= shipping_method[:name] %> <%= number_to_currency shipping_method[:cost] %></label>
20: <div class="clear"></div>
app/views/checkout/_payment.html.erb:17:in `_app_views_checkout__payment_html_erb___481978343_67756860_4938188'
app/views/checkout/edit.html.erb:7:in `_app_views_checkout_edit_html_erb__453920959_66761340_0'
@imustardsoft
imustardsoft / gist:1347754
Created November 8, 2011 13:37
price_bucket.rb
class Calculator::PriceBucket < Calculator
preference :minimal_amount, :decimal, :default => 0
preference :normal_amount, :decimal, :default => 0
preference :discount_amount, :decimal, :default => 0
def self.description
I18n.t("price_bucket")
end
# as object we always get line items, as calculable we have Coupon, ShippingMethod
@imustardsoft
imustardsoft / gist:1347759
Created November 8, 2011 13:38
Spree Order.rb
# total amount of the order, only considering item cost
def amount
self.line_items.map(&:amount).sum
end
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpC35S4+PUe8vbraqdRX76aQq8+yhumx7EdQlAaoPUJwqrX/EaY1SBJnkIRczQEpMcxCl66kIpWV1PywIm8zlaVAbUj9xwdtlcG5dHn6hBtpzWBY1B3PbN4nsO/cXOx5yJn0beqo71iJDKq9YRkmQlLU6qEeEx0CRNR/ulx9XsFqOx8tB/5idkQ5algxDLhnyOojKsEWkByr7NOJLNaeeOjm5ivsIzsK7mL+WQPzeJhi2t6q0UWb44YdVTT7GJD9isRNpAnhC19rK6Oj3MD4EEppMGN6inMpZuPhpeIECsAv6Ahc86Jj7MTrGxBx7E1Kp3EiqU62Y3oskCP99QKnHT