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 UserPasswordResetsController < ApplicationController | |
#personal preferences here | |
def update | |
user = User.find_by(password_reset_token: params[:id]) | |
if !user.present? | |
head :not_found | |
elsif !(user.is_activated && user.is_active) | |
head :unprocessable_entity | |
elsif user.update_password params[:password], params[:password_confirmation] | |
head :ok |
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 Admin < User | |
has_one :user, :as => :userable | |
attr_accessible :user | |
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
pow(pow(x, n / 2), 2) | |
pow(x, n / 2) * pow(x, n / 2) |
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 Feature < ActiveRecord::Base | |
has_one :project_item, as: :item, class_name: "ProjectItem" | |
end | |
class Milestone < ActiveRecord::Base | |
has_one :project_item, as: :item, class_name: "ProjectItem" | |
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
irb(main):001:0> User.create(name: "dudu", email: "[email protected]", password: "1234", password_confirmation: "1234") | |
(1.0ms) begin transaction | |
User Exists (0.0ms) SELECT 1 AS one FROM "users" WHERE LOWER("users"."email") = LOWER('[email protected]') LIMIT 1 | |
Binary data inserted for `string` type on column `password_digest` | |
SQL (4.0ms) INSERT INTO "users" ("created_at", "email", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ? | |
[["created_at", Mon, 18 Nov 2013 20:50:04 UTC +00:00], ["email", "[email protected]"], ["name", "dudu"], ["password_digest | |
2a$10$ENowSeWI6nGZbVIHVUBfuuwKEWeZ9I81Ci/Nru2Q6Q0.paUi7kFXu"], ["updated_at", Mon, 18 Nov 2013 20:50:04 UTC +00:00]] | |
(74.1ms) commit transaction | |
=> #<User id: 5, name: "dudu", email: "[email protected]", created_at: "2013-11-18 20:50:04", updated_at: "2013-11-18 20:50 | |
password_digest: "$2a$10$ENowSeWI6nGZbVIHVUBfuuwKEWeZ9I81Ci/Nru2Q6Q0...."> |
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 Movie < ActiveRecord::Base | |
belongs_to :channel | |
validate :does_not_overlap, :valid_times | |
def self.from_xml(xml) | |
id = xml.attr('id') #parse movie id | |
channel = Channel.find_by_codename(xml.child.name) #get the channel from db | |
name = xml.child.xpath('name').text #get name | |
start_time = parse_time(xml.child.xpath('start_time').text) | |
end_time = parse_time(xml.child.xpath('end_time').text) |
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 Manufacturer < ActiveRecord::Base | |
def self.selectable | |
result = [] | |
result << self.joins(:cars).joins(cars: :basic_articles).where(published: true, cars:{published: true}, basic_articles: {published: true, requires_extra: false}).map{ |r| r.id } | |
result << self.joins(:cars).joins(cars: :basic_articles).joins(cars: [basic_articles: :extras]).where(published: true, cars:{published: true}, basic_articles: {published: true, requires_extra: true}).map{ |r| r.id } | |
return self.where(id: result) | |
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 Member < ActiveRecord::Base | |
belongs_to :project | |
belongs_to :users | |
attr_accessible :project_id, :user_id | |
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 Member < ActiveRecord::Base | |
belongs_to :project | |
belongs_to :users | |
attr_accessible :project_id, :user_id | |
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
<p> | |
<b>Comment:</b> | |
<%= comment.body %> | |
</p> | |
<p> | |
<%= link_to 'Destroy Comment', [comment.post, comment], | |
:confirm => 'Are you sure?', | |
:method => :delete %> | |
</p> |