This file contains hidden or 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
serialize :product_categories | |
<%= select_product_categories(@vendor.registration_request.product_categories) %> | |
def select_product_categories(array) | |
if array == nil or array.length == 0 | |
array = [] | |
end |
This file contains hidden or 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
@users.sort! { |a,b| a.name.downcase <=> b.name.downcase } |
This file contains hidden or 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 this file in the header | |
// And also add the following to the bottom of whatever partial you're using | |
// <script type="text/javascript"> | |
// $("#pl_<%= index %>_full").charCount({counterText: '文字数:', transCost: 15, language: '#locale_<%= index %>'}); | |
// </script> | |
(function($) { | |
$.fn.charCount = function(options){ | |
This file contains hidden or 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
erb = ERB.new("<%= @vendor.email %>") | |
@mytext = erb.result(binding) |
This file contains hidden or 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
/* SMTP variables を設定 | |
http://forum.whmcs.com/showthread.php?t=13845 | |
↑の設定のほぼパクリ。ただ、もとネタのように、 "tls://" を tls のトリガーに使ってしまうと、コロンのせいで explode されてしまう。(e.g. "smtp1.example.com:25;smtp2.example.com")のフォーマットに対応するため。。。 | |
なので、 tls// のみをトリガーにする。後の strpos 部分と一致してれば、トリガーは何の文字列でもOK。 | |
*/ | |
///////////////////////////////////////////////// | |
// SMTP VARIABLES | |
///////////////////////////////////////////////// | |
var $Host = "tls//smtp.gmail.com"; // the "tls//" is used later to trigger tls |
This file contains hidden or 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
<script type="text/javascript"> | |
function send(){ | |
// check "send_now" and submit using ajax | |
// Assumes you're using jquery.rails.js | |
$("#send_now").val("true"); | |
$("#f").trigger("submit"); | |
}; | |
</script> | |
<input type='hidden' id='send_now' name='send_now' /> |
This file contains hidden or 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
Different ways in which you can use the form_for helper. | |
<%= form_for([:admin, @order], :html => {:multipart => true, :class => "std", :name=>'f' }) do |f| %> | |
<%= form_for(@order, :url=> somepath, :html => {:method => :put, :class => "std", :name=>'f' }) do |f| %> | |
<%= form_for("order[something]", :url=> somepath, :html => {:method => :put, :class => "std", :name=>'f' }) do |f| %> | |
This file contains hidden or 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
sql = "SELECT DISTINCT p.id, p.name as original_name, p.thumbnail_file_name, p.sku, | |
pv.vendor_id, pv.price, pv.stock, pv.display_stock, pv.free_shipping, | |
pl.name, pl.short | |
FROM products as p | |
INNER JOIN product_vendors AS pv ON pv.product_id = p.id AND pv.vendor_id = ? | |
LEFT JOIN product_languages AS pl ON pl.product_id = p.id AND pl.locale = ? | |
WHERE p.id in (SELECT product_id FROM newsletter_products where newsletter_id = ?) | |
ORDER BY " |
This file contains hidden or 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 link_to_remove_fields(name, f) | |
# See corresponding remove_fields function in application.js | |
f.hidden_field(:_destroy) + link_to(name, nil, :onclick => "remove_fields(this)", :remote=>true) | |
end | |
def link_to_add_fields(name, f, association) | |
new_object = f.object.class.reflect_on_association(association).klass.new | |
fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| | |
render(association.to_s.singularize + "_fields", :f => builder) | |
end |
This file contains hidden or 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
# config/initializers/errors_i18n.rb | |
ActiveModel::Errors.module_eval do | |
def full_messages | |
full_messages = [] | |
each do |attribute, messages| | |
messages = Array.wrap(messages) | |
next if messages.empty? |