-
The -j option of the application generator accepts an arbitrary string. If passed "foo", the gem "foo-rails" is added to the Gemfile, and the application JavaScript manifest requires "foo" and "foo_ujs". As of this writing "prototype-rails" and "jquery-rails" exist and provide those files via the asset pipeline. Default is "jquery". [fxn]
-
jQuery is no longer vendored, it is provided from now on by the jquery-rails gem. [fxn]
-
Prototype and Scriptaculous are no longer vendored, they are provided from now on by the prototype-rails gem. [fxn]
-
The scaffold controller will now produce SCSS file if Sass is available [Prem Sichanugrist]
This file contains 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
class ReportsController < ApplicationController | |
def index | |
@reports = Report.all | |
end | |
def show | |
@report = @technician.report.find(params[:id]) | |
end | |
def new |
This file contains 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
class UploadsController < ApplicationController | |
def create | |
... | |
@upload.shape = "photo" | |
... | |
if @upload.save | |
... | |
end |
This file contains 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
class Upload < ActiveRecord::Base | |
belongs_to :uploadable, :polymorphic => true | |
attr_accessible :uploadable_id, :uploadable_type, :attachment, :shape, :description | |
# Make :parent_type available for Paperclip :path & :url options. | |
# Path on S3 should contain the parent class (e.g. "member") for | |
# better readability. | |
Paperclip.interpolates :parent_type do |attachment, style| |
This file contains 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
Here we get :parent_type --> works √ | |
Paperclip.interpolates :parent_type do |attachment, style| | |
attachment.instance.uploadable_type.downcase | |
end | |
Here, :parent_type works in :path => but not in Proc, how do I solve this? | |
has_attached_file :attachment, | |
:path => ":class/:parent_type/:id/:style.:extension", |
This file contains 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
module Paperclip | |
class Attachment | |
def self.default_options | |
@default_options ||= { | |
:url => ":attachment/:id/:style.:extension", | |
:path => ":rails_root/public:url", | |
:s3_credentials => "#{Rails.root}/config/s3.yml", | |
:storage => :s3, | |
:styles => {}, | |
:processors => [:thumbnail], |
This file contains 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
class Game < ActiveRecord::Base | |
has_many :photos, :as => :picturable, :dependent => :destroy | |
accepts_nested_attributes_for :photos, :allow_destroy => true, :reject_if => lambda { |a| a[:picture].blank? } | |
end | |
should be outsourced into a module like | |
=> /lib/attachment.rb |
This file contains 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
# Change prefix key to Ctrl+a | |
unbind C-b | |
set -g prefix C-a | |
# Last active window | |
unbind l | |
bind C-a last-window | |
# Copy mode | |
unbind [ |
NewerOlder