Skip to content

Instantly share code, notes, and snippets.

@ArunGupta25
ArunGupta25 / en.yml
Last active December 29, 2015 20:48
overriding the registrations controller
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"
mailboxer:
message_mailer:
subject_new: "new %{type} from %{sender}"
subject_reply: "new %{type} from %{sender}"
en:
@ArunGupta25
ArunGupta25 / controller code
Created October 27, 2013 05:24
server error
def index
if params["rawdenim"]
params["raw denim"] = params["rawdenim"]
end
if params[:gotouser] == "yes"
if current_user
redirect_to user_path(current_user.id)
end
end
@perpage = 60
@ArunGupta25
ArunGupta25 / params hash
Last active December 26, 2015 11:29
activerecord query
# params[:category] is an array of categories like ['tops, 'bottoms', 'outerwear'].
# For each category I have a corresponding array of sizes like ['M', 'L'].
# params[category] gives the sizes for the category.
#I want to return the given sizes in each category so I've created this loop.
# However I don't know how to merge the queries together. I think I'm supposed to use .merge but I'm not sure what to define @listings as so I can call .merge on it in the loop.
@listings = []
params[:category].each do |category|
@listings += Listing.where(category: category, size: params[category], designer: params[:designer], sold: nil).include(:photos).page(params[:category_page]).per(@perpage)
@ArunGupta25
ArunGupta25 / css
Last active December 26, 2015 06:29
@font-face {
font-family: "SackersGothicStd-Light";
src: url('<%= asset_path('SackersGothicStd-Light.otf') %>');
}
en:
hello: "Hello world"
mailboxer:
message_mailer:
subject_new: "Sartorialis - %{sender}"
subject_reply: "Sartorialis - %{sender}"
submitHandler: function(form) {
jQuery.facebox({ div: '#loading' });
form.submit();
}
@ArunGupta25
ArunGupta25 / update action
Created October 16, 2013 01:00
rails error, private method
NoMethodError in ListingsController#update
private method `update' called for #<Listing:0x007fc33f857e60>
Rails.root: /Users/arungupta/sartorialis
Application Trace | Framework Trace | Full Trace
app/controllers/listings_controller.rb:46:in `block in update'
app/controllers/listings_controller.rb:45:in `update'
Request
jQuery ->
$(document).on "click",'.pagination a[data-remote=true]', (e) ->
history.replaceState {}, '', $(@).attr('href')
# encoding: utf-8
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
# include Sprockets::Helpers::RailsHelper
$(".saved-cc-button").click(function () {
$("#savedpayer").hide();
$("#paying").show();
$.ajax({
type: 'POST',
url: '/stripe',
data: { loggedinid : <%= current_user.id %> },
headers: {
'X-Transaction': 'POST Example',
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')