validates :name, :email, presence: true
validates :terms_of_service, acceptance: true
validates :email, format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i, message: "Valid email required" }
$("#follow_form").html("<%= escape_javascript(render('users/unfollow')) %>") | |
$("#followers").html('<%= @user.followers.count %>') |
def rollback_packages | |
self.lines.each do |l| | |
l.packages each do |p| | |
puts "INside the nested deal" | |
begin | |
ActiveRecord::Base.transaction do | |
p.update_attributes(:sold => false, :line_id => nil) | |
end | |
rescue => e | |
self.errors[:base] << e.message |
# these all accomplish the same goal. | |
def sum(numbers=[]) | |
sum = 0 | |
numbers.each { |i| sum += i } | |
sum | |
end | |
def sum(numbers=[]) | |
numbers.inject(0) { |sum,element| sum += element } |
# The each method is an iterator. It invokes a block of code a certain amount of times. The amount of times | |
# it will invoke the block of code depends on the size of the collection (array or hash) it is called on. | |
# for example, calling each on an array could be done like this: | |
[1,2,3].each do |num| | |
puts num | |
end | |
# this returns: | |
1 |
validates :name, :email, presence: true
validates :terms_of_service, acceptance: true
validates :email, format: { with: /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i, message: "Valid email required" }
For anyone using a Mac (Lion) and running into issues with Postgres as your database (with Postgres.app):
If you are using Postgres.app and getting errors…
If the the result is /usr/bin/psql you are using the Mac's built in postgres (not the one you want)
which
prints out the full path of the command it's passed. For example, try typing which pwd
into your command line. You should see /bin/pwd
as the result. This simply means that the executable command for pwd
is stored in the /bin
directory.
Like Mike noted, if you run which psql
, and the result is /usr/bin/psql
it means that the executable command for your Postgresql database server is in the /usr/bin
directory, which means Bash
isn't going to run the Postgres.app database server.
Bash is an old Unix acronym, which stands for 'Bourne-Again Shell' As you can probably guess, it's just a pun on the name of Stephen Bourne, who authored the original Bourne shell, which is the foundation for the command line interface in Unix. (Mac OS is based on Unix).
The .bash_profile
is a file that states which commands will be executed when you open your terminal. (aka Bash).
2013-05-15T20:35:41.399417+00:00 app[web.1]: Rendered devise/shared/_links.erb (0.6ms) | |
2013-05-15T20:35:41.399417+00:00 app[web.1]: Rendered devise/registrations/new.html.erb within layouts/application (6.3ms) | |
2013-05-15T20:35:41.399417+00:00 app[web.1]: Completed 200 OK in 12ms (Views: 11.0ms | ActiveRecord: 0.0ms) | |
2013-05-15T20:35:41.400658+00:00 heroku[router]: at=info method=GET path=/users/sign_up host=bloccit.herokuapp.com fwd="65.206.21.165" dyno=web.1 connect=0ms service=25ms status=200 bytes=3289 | |
2013-05-15T20:35:41.399417+00:00 app[web.1]: Processing by Devise::RegistrationsController#new as HTML | |
2013-05-15T20:35:41.882902+00:00 heroku[router]: at=info method=GET path=/assets/application-770fe5755077bd5022e97daf1c747e09.js host=bloccit.herokuapp.com fwd="65.206.21.165" dyno=web.1 connect=5ms service=357ms status=304 bytes=0 | |
2013-05-15T20:35:49.243880+00:00 app[web.1]: Started POST "/users" for 65.206.21.165 at 2013-05-15 20:35:47 +0000 | |
2013-05-15T20:35:50.492979+00:00 heroku[router]: at=info met |
source 'https://rubygems.org' | |
gem 'rails', '3.2.12' | |
group :assets do | |
gem 'sass-rails', '~> 3.2.3' | |
gem 'bootstrap-sass', '~> 2.3.1.0' | |
gem 'coffee-rails', '~> 3.2.1' | |
gem 'uglifier', '>= 1.0.3' | |
end |
Build an application that allows users to manage Sidekiq services. We'll call this application "Sidekicker", but you can name it anything you want.
Sidekiq is a background processing service that can be integrated into Rails applications. Basically, Sidekiq can make Rails applications much faster and more efficient. When you're maintaining many applications that use Sidekiq, it's cumbersome to manage each Sidekiq instance separately. Therefore we'll build the Sidekicker app, which will present a central location to manage Sidekiq services for all the apps that you are maintaining.
We'll assume that all of our applications will be built using Amazon's AWS servers, so the Sidekicker app will need a way to communicate with AWS, and run Sidekiq services on Amazon servers.