This file contains hidden or 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
schemaverse=> LISTEN jdcyekurqi; | |
LISTEN | |
schemaverse=> NOTIFY jdcyekurqi, 'some text'; | |
NOTIFY | |
Asynchronous notification "jdcyekurqi" received from server process with PID 2931. | |
schemaverse=> SELECT 1; | |
?column? | |
---------- | |
1 | |
(1 row) |
This file contains hidden or 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
schemaverse=> NOTIFY jdcyekurqi, 'some text'; | |
NOTIFY | |
schemaverse=> SELECT 1; | |
?column? | |
---------- | |
1 | |
(1 row) |
This file contains hidden or 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
SELECT my_ships.id as ship_id, ( | |
SELECT planets.id | |
FROM planets | |
WHERE id NOT IN(SELECT id FROM planets WHERE conqueror_id=2599) | |
ORDER BY SQRT(((planets.location_x::bigint+-my_ships.location_x::bigint)^2) + ((my_ships.location_y::bigint-planets.location_y::bigint)^2)) | |
ASC OFFSET 0 LIMIT 1) as planet_id | |
FROM my_ships; |
This file contains hidden or 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
<%= select_tag :other_select, options_for_select(@collection) %> |
This file contains hidden or 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
scope :current, where(:current=>true} | |
validate :only_one_current | |
protected | |
def only_one_current | |
errors.add_to_base("Only one event can be current") if Event.current.reject{|c| c.eql?(self)}.size>0 | |
end |
This file contains hidden or 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 show | |
authorize! :assignment, :show | |
@assignment = Assignment.find(params[:id]) | |
@related_logs = @assignment.assignment_logs.page(params[:page]).per(4).order('assignment_logs.date DESC').includes(:user) | |
# do a find to find and order candidates by there current employment | |
@candidates = AssignmentList.where('assignment_lists.assignment_id = ?', @assignment.id) |
This file contains hidden or 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
# AJAX request: This adds line items to cart. | |
def add_line_item_to_cart | |
#Get current_cart object | |
current_cart | |
quantity = params[:quantity].to_i | |
id = params[:id].to_i | |
line_item = LineItem.find_or_create_by_cartridge_id_and_cart_id(id, current_cart.id) | |
line_item.quantity = line_item.quantity.to_i + quantity |
This file contains hidden or 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
@comment.update_attributes(:commentable_id=>nil, :commentable_type=>nil) | |
=> true | |
>> @comment.reload | |
@comment.reload | |
=> #<Comment id: 2, created_at: "2010-04-29 14:54:07", updated_at: "2010-04-29 15:05:32", content: "Hello", commentable_id: nil, commentable_type: nil> | |
>> @comment.commentable |
This file contains hidden or 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 Comment < ActiveRecord::Base | |
belongs_to :commentable, :polymorphic=>true | |
end | |
class Article < ActiveRecord::Base | |
has_many :comments, :as => :commentable | |
end | |
############################################### |
This file contains hidden or 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
>> @article = Article.new | |
@article = Article.new | |
=> #<Article id: nil, created_at: nil, updated_at: nil> | |
>> @article.comments.build(:content=>"Hello") | |
@article.comments.build(:content=>"Hello") | |
=> #<Comment id: nil, created_at: nil, updated_at: nil, content: "Hello", commentable_id: nil, commentable_type: "Article"> |