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
# post_controller.rb | |
class PostsController < ApplicationController | |
def index | |
@posts = Post.find(:all) | |
end | |
def new | |
@post = Post.new | |
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
Hear is the server output. I explicitly hit the upvote link for demo purposes. This is also the server output with the suggested edit of replacing boolean values with strings in my post.rb model for the method vote_total. As far as I can understand, no matter which link I select (up or down vote), the value starts properly but gets submitted as 0. | |
Here is my updated Post.rb model containing the vote_total method. | |
class Post < ActiveRecord::Base | |
attr_accessible :URL, :description, :is_link | |
has_many :comments, dependent: :destroy | |
has_many :votes, dependent: :destroy |
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
# controllers/assessment_plan_form_controller.rb | |
class AssessmentPlanFormsController < ApplicationController | |
before_filter :get_resident | |
def index | |
@assessment_plan_forms = @resident.assessment_plan_forms | |
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
<%= f.date_select(:form_date, order: [:month, :day, :year], prompt: { month: 'Select Month', day: 'Select Day', year: 'Select Year' }, start_year: 2000, size: 1) |
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
Started GET "/residents/1" for 127.0.0.1 at 2013-07-07 17:47:03 -0400 | |
Processing by ResidentsController#show as HTML | |
Parameters: {"authenticity_token"=>"TkgTe0hwIOCaHtU6UxXrh6QVOd4YDoK26svqX/lJVfk=", "id"=>"1"} | |
Admin Load (0.4ms) SELECT "admins".* FROM "admins" WHERE "admins"."id" = 1 LIMIT 1 | |
Resident Load (1.6ms) SELECT "residents".* FROM "residents" | |
Resident Load (1.2ms) SELECT "residents".* FROM "residents" WHERE "residents"."id" = ? LIMIT 1 [["id", "1"]] | |
AssessmentPlanForm Load (1.0ms) SELECT "assessment_plan_forms".* FROM "assessment_plan_forms" | |
AssessmentPlanForm Load (1.0ms) SELECT "assessment_plan_forms".* FROM "assessment_plan_forms" WHERE "assessment_plan_forms"."resident_id" = 1 AND "assessment_plan_forms"."id" = ? LIMIT 1 [["id", "1"]] | |
Rendered chart_alerts/up_to_date/_assessment_plan_form_success_alert.html.erb (0.1ms) | |
MedRecordForm Load (9.7ms) SELECT "med_record_forms".* FROM "med_record_forms" |
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
[2013-08-21 13:19:48] INFO WEBrick 1.3.1 | |
[2013-08-21 13:19:48] INFO ruby 2.0.0 (2013-06-27) [x86_64-darwin10.8.0] | |
[2013-08-21 13:19:48] INFO WEBrick::HTTPServer#start: pid=11295 port=3000 | |
Started GET "/subscriptions" for 127.0.0.1 at 2013-08-21 13:19:52 -0400 | |
Processing by SubscriptionsController#index as HTML | |
Subscription Load (0.7ms) SELECT "subscriptions".* FROM "subscriptions" | |
Rendered subscriptions/index.html.erb within layouts/application (15.3ms) | |
Rendered layouts/_shim.html.erb (6.5ms) |
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 Song | |
def initialize(self, artist, title, genre) | |
@song = Self.new | |
@artist = artist | |
@title = title | |
@genre = genre | |
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
# account.rb | |
class Account | |
def initialize | |
@balance = 1000.00 | |
end | |
attr_accessor :amount | |
def send_deposit | |
"#{deposit(amount, current_balance).to_f}" |
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
# interact.rb | |
require_relative 'account' | |
class Interact | |
def greeting | |
puts "Welcome to bank." | |
end | |
def farewell | |
puts "Have a good day, we value your money here at bank." |
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
# banking.rb | |
require_relative 'interact' | |
require_relative 'account' | |
deposit = Account.new | |
withdraw = Account.new | |
banking = Interact.new | |
puts "#{banking.greeting}" |
OlderNewer