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
def create | |
begin | |
n = Mikolaj.create_from_text(params[:s]) | |
respond_to |format| | |
format.html { redirect_to mikolajs_path, notice: "Dodano #{n} mikolajow" } | |
format.json { render json: mikolajs_path, status: :created, location: mikolajs_path } | |
end | |
rescue ActiveRecord::RecordInvalid | |
render :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 Post | |
def comment=(val) | |
comment = val | |
self.comment | |
end | |
end | |
comment = Post.new | |
comment.comment = 'My Comment' |
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 Product < ActiveRecord::Base | |
include HstoreAccessor | |
hstore_accessor :data, :price, :weight | |
end | |
p = Product.new | |
p.price = '$45' | |
p.price #=> $45 |
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 Product < ActiveRecord::Base | |
[:price, :weight].each do |e| | |
define_method e do | |
data && data[e.to_s] | |
end | |
define_method :"#{e}=" do |val| | |
self.data = (data || {}).merge(e => val) | |
end | |
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 Product < ActiveRecord::Base | |
def price | |
data && data['price'] | |
end | |
def price=(val) | |
self.data = (data || {}).merge(price: val) | |
end | |
def weight |
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 HstoreAccessor | |
extend ActiveSupport::Concern | |
module ClassMethods | |
# Define accessors method for HStore field | |
# | |
# @param [Symbol] hstore name of HStore field | |
# @param [Array] fields list of accessors methods to define | |
def hstore_accessor(hstore, *fields) | |
fields.each do |field| |
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
$ cd ~/Library/Preferences/RubyMine40/colors | |
$ wget https://raw.github.com/gist/2011486/TommorowNight.xml |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<scheme name="Tomorrow Night" version="1" parent_scheme="Default"> | |
<option name="LINE_SPACING" value="1.0" /> | |
<option name="EDITOR_FONT_SIZE" value="12" /> | |
<option name="CONSOLE_FONT_NAME" value="Monospaced" /> | |
<option name="EDITOR_FONT_NAME" value="Menlo" /> | |
<colors> | |
<option name="ADDED_LINES_COLOR" value="c5c8c6" /> | |
<option name="ANNOTATIONS_COLOR" value="ffffff" /> | |
<option name="ANNOTATIONS_MERGED_COLOR" value="ffffff" /> |
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
* executing `bundle:install' | |
* executing "ls -x /home/prima/www/prima-rewal/releases" | |
servers: ["prima.megiteam.pl"] | |
[prima.megiteam.pl] executing command | |
[prima.megiteam.pl] sh -c 'ls -x /home/prima/www/prima-rewal/releases' | |
command finished in 542ms | |
* executing "cd /home/prima/www/prima-rewal/releases/20120305212839 && bundle install --gemfile /home/prima/www/prima-rewal/releases/20120305212839/Gemfile --path /home/prima/www/prima-rewal/shared/bundle --deployment --quiet --without development test" | |
servers: ["prima.megiteam.pl"] | |
[prima.megiteam.pl] executing command | |
[prima.megiteam.pl] sh -c 'cd /home/prima/www/prima-rewal/releases/20120305212839 && bundle install --gemfile /home/prima/www/prima-rewal/releases/20120305212839/Gemfile --path /home/prima/www/prima-rewal/shared/bundle --deployment --quiet --without development test' |
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
prima@vk1062:~$ gem list | grep v8 | |
libv8 (3.3.10.4 x86_64-linux) | |
prima@vk1062:~$ gem list | grep therubyracer | |
prima@vk1062:~$ gem install therubyracer | |
Building native extensions. This could take a while... | |
ERROR: Error installing therubyracer: | |
ERROR: Failed to build gem native extension. | |
/usr/local/ruby-1.9/bin/ruby extconf.rb | |
creating Makefile |
NewerOlder