Skip to content

Instantly share code, notes, and snippets.

View ExByt3s's full-sized avatar
🎯
Focusing

ExByt3s

🎯
Focusing
  • nothing
  • caracas/venezuela
View GitHub Profile
@ExByt3s
ExByt3s / gist:e2a3be272161ca1414da
Created January 19, 2015 18:04
rails guide problem
sirene@cleopatra:~/Escritorio/rails-master$ cd guides
sirene@cleopatra:~/Escritorio/rails-master/guides$ ls
assets bug_report_templates CHANGELOG.md rails_guides rails_guides.rb Rakefile source w3c_validator.rb
sirene@cleopatra:~/Escritorio/rails-master/guides$ rake guides:generate:html
/usr/local/bin/ruby rails_guides.rb
/home/sirene/Escritorio/rails-master/actionpack/lib/action_controller/metal/strong_parameters.rb:528:in `<class:Parameters>': cannot load such file -- rack/test (LoadError)
from /home/sirene/Escritorio/rails-master/actionpack/lib/action_controller/metal/strong_parameters.rb:106:in `<module:ActionController>'
from /home/sirene/Escritorio/rails-master/actionpack/lib/action_controller/metal/strong_parameters.rb:10:in `<top (required)>'
from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `require'
from /usr/local/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:126:in `require'
@ExByt3s
ExByt3s / gist:7e13e98818d4c7b99488
Created January 20, 2015 03:36
`original_filename'
undefined method `original_filename' for "4896_EN_ROW_W52_Phones_868x250_12_12_2014_4_35_30_784.jpg":String
def create
@audition = Audition.create(_audition_param_)
@retail = @audition.retails.build(rettailram)
@imagenes = @audition.imagens.build(imagen_attributes)
uploaded_io = params[:Imagen][:ico]
File.open(Rails.root.join('public', 'data', uploaded_io.original_filename), 'wb') do |file|
utf8"=>"✓", "authenticity_token"=>"FLAnBUVKZjPmCvCeeTV0wXnWDS2XvXjVFwUeSfdX3L+qdzVewEK6s3rBBtr2LXoSfI8QTUGqr7Z3J0QbAaqQYw==", "audition"=>{"name"=>"sassssssssssssssssssssssssssssssssssssssssssssssssssssss", "description"=>"sdfdsfddddddddddddddddddddddddddddd"}, "Retail"=>{"price"=>"66", "unit"=>"6"}, "Imagen"=>{"uploads"=>#<ActionDispatch::Http::UploadedFile:0x007f5c9e31f798 @tempfile=#<Tempfile:/tmp/RackMultipart20150121-11876-zokizh.css>, @original_filename="iw_sprite.css", @content_type="text/css", @headers="Content-Disposition: form-data; name=\"Imagen[uploads]\"; filename=\"iw_sprite.css\"\r\nContent-Type: text/css\r\n">}, "commit"=>"sell it", "controller"=>"auditions", "action"=>"create"}
when i add that validation
validates_format_of :uploads, :with => /\A.(jpg) \Z/i

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@ExByt3s
ExByt3s / audition.rb
Last active August 29, 2015 14:15
auditions_controller.rb
class Audition < ActiveRecord::Base
attr_writer :current_step
attr_accessor :brand
before_create :audition_time
belongs_to :category
has_many :prices
has_many :specifications
accepts_nested_attributes_for :specifications, reject_if: :all_blank, allow_destroy: true
@ExByt3s
ExByt3s / seeds.rb
Created February 9, 2015 22:37
bulk category xD
subcategories
@ExByt3s
ExByt3s / seeds.rb
Created February 9, 2015 22:38
bulk category T___T
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
#
Category.delete_all
class Category < ActiveRecord::Base
belongs_to :root, class_name: "Category", :foreign_key => "category_id"
has_many :subcategories, class_name: "Category", foreign_key: "category_id"
has_many :auditions
// Place all the styles related to the logins controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.pgfmr {
.pgfrm_left {
padding: 20px;
width: 50%;
height: 500px;
def force_login
if !current_user
flash[:error]="Only logged in users can sell products.
Please #{view_context.link_to("Log in", :controller=>'logins', :action=>'new')}
and #{view_context.link_to("Sign up", :controller=>'users', :action=>'new')}if you don't have an account"
redirect_to auditions_url
end
end