Skip to content

Instantly share code, notes, and snippets.

View maier-stefan's full-sized avatar
🏠
Working from home

Stefan Maier maier-stefan

🏠
Working from home
View GitHub Profile
@maier-stefan
maier-stefan / change_shipping_country
Last active August 29, 2015 14:05
From select tag to link to
<%= form_for :country, :url => {:action =>"change_shipping_country", :controller => "/application"}, :html => {:method => "post"} do |f| %>
<%= select_tag :code2, options_from_collection_for_select(Country.ordered, :code2, :name, @shipping_country.code2), :onchange => "this.form.submit()" %>
<% end %>
<ul>
<%= form_for :country, :url => {:action =>"change_shipping_country", :controller => "/application"}, :html => {:method => "post"} do |f| %>
<li>
<%= submit_tag "#{t :germany}", :name => "germany_button" do %>
<img src="/images/location-de.png">
<% end %>
@maier-stefan
maier-stefan / gist:de24c059e8ac5260f0f8
Created August 24, 2014 16:22
select product option
my route
get 'products/:id(/:color_id(/:size_id))' => 'products#show', :as => "select_product_option"
in my product_group model
def size size_id
return nil unless size_id
product_sizes.find(size_id)
end
@maier-stefan
maier-stefan / gist:b7eb526532c51eef6249
Last active August 29, 2015 14:05
Scope Language and Shipping Country
Routes:
scope ":country", country: /#{Country.pluck(:code2).join("|")}/ do
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
root :to => "pages#home"
end
end
<% if @customer.errors.any? %>
<div class="warning">
<h2><%= @customer.errors.count %> <%= t :error_prohibited_save %></h2>
<ul>
<% @customer.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
@maier-stefan
maier-stefan / gist:9aaa92bf0cfce304b254
Last active August 29, 2015 14:06
Collection Select
I have a multiselect with checkboxes:
<%= f.label :Category, :class => 'control-label' %>
<% Category.all.each do |category| -%>
<div>
<%= check_box_tag :category_ids, category.id, @job.categories.include?(category), :name => 'job[category_ids][]' %>
<%= label_tag :category_ids, category.name %>
</div>
<% end %>
@maier-stefan
maier-stefan / gist:e96c4d9ba37be3375a2b
Created September 21, 2014 12:35
Newsletter opt out
Controller Action
def newsletter_opt_out
@newsletter = Newsletter.find_by_email(:email)
@newsletter.destroy
respond_to do |format|
format.html {redirect_to :back, notice: t('newsletter_opt_out')}
end
end
<<<<<<< HEAD
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="checkbox">
<label class="checkbox-skin" data-toggle="#billing-address">
<%= f.check_box :separate_billing_address %>
<%= t :want_separate_billing_address %></label>
</div>
</div>
</div>
@maier-stefan
maier-stefan / gist:41d2634aa023ca074da0
Created September 24, 2014 08:51
Checkbox trigger
$('.radio-skin, .checkbox-skin').on('click', function(event){
event.preventDefault();
var $label = $(this),
$input = $label.find('input');
if ($input.attr('checked')) {
@maier-stefan
maier-stefan / gist:b1c811ce8e5ec87a6755
Created October 5, 2014 14:11
Get_DATA_FROM_APPLE
def get_data_from_apple id
@object = JSON.parse(open("https://itunes.apple.com/lookup?id=#{id}").read)
end
@maier-stefan
maier-stefan / Solution of SSL
Last active August 29, 2015 14:07
SSL Error - ssl_error_rx_record_too_long
user nginx;
worker_processes {{ workers }};
error_log {{ deploy_to }}/shared/log/nginx_error.log;
events
{
worker_connections 1024;
{% if passenger != true %}
accept_mutex off;
{% endif %}