Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: o-schneider/sample_app
...
head fork: o-schneider/sample_app
  • 4 commits
  • 15 files changed
  • 0 commit comments
  • 2 contributors
Commits on Feb 17, 2012
Olivier Schneider Add dynamic gravatar size f78fce6
Olivier Schneider Translate password_digest into Password ab176e3
Commits on Mar 04, 2012
Olivier SCHNEIDER Finish chapter 7 f33e0e3
Olivier SCHNEIDER Merge branch 'develop' e65ef4e
View
5 app/helpers/users_helper.rb
@@ -1,9 +1,10 @@
module UsersHelper
# Return the gravatar of a given user
- def gravatar_for(user)
+ def gravatar_for(user, options = {size: 40})
gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
- gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png"
+ size = options[:size]
+ gravatar_url = "http://gravatar.com/avatar/#{gravatar_id}.png?size=#{size}"
image_tag(gravatar_url, alt: user.name, class: "gravatar")
end
View
11 app/models/user.rb
@@ -2,11 +2,12 @@
#
# Table name: users
#
-# id :integer not null, primary key
-# name :string(255)
-# email :string(255)
-# created_at :datetime not null
-# updated_at :datetime not null
+# id :integer not null, primary key
+# name :string(255)
+# email :string(255)
+# created_at :datetime not null
+# updated_at :datetime not null
+# password_digest :string(255)
#
class User < ActiveRecord::Base
View
3  app/views/layouts/application.html.erb
@@ -12,13 +12,14 @@
<section class="round">
<% flash.each do |key, value| %>
- <div class="flash <%= key %>"><%= value %></div>
+ <%= content_tag(:div, value, class: "flash #{key}") %>
<% end %>
<%= yield %>
</section>
<%= render 'layouts/footer' %>
<%= debug(params) if Rails.env.development? %>
+ <%= t "helloworld" %>
</div>
</body>
</html>
View
2  app/views/users/show.html.erb
@@ -3,7 +3,7 @@
<tr>
<td class="main">
<h1>
- <%= gravatar_for @user %>
+ <%= gravatar_for @user, params%>
<%= @user.name %>
</h1>
</td>
View
5 config/locales/en.yml
@@ -2,4 +2,7 @@
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
- hello: "Hello world"
+ activerecord:
+ attributes:
+ user:
+ password_digest: "Password"
View
42 sample_app.ids
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?><component name="dataSourceStorage">
+ <data-source source="LOCAL" name="Rails sample_app: development" product="SQLite" version="3.6.3" jdbc-version="2.1" driver-version="native" uuid="429f89c5-6177-4d0c-bfd0-2f64e67ff9a5">
+ <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
+ <jdbc-url>jdbc:sqlite:/home/oli/Development/Rails/sample_app/db/development.sqlite3</jdbc-url>
+ <libraries>
+ <library>
+ <url>file://$USER_HOME$/.IntelliJIdea11/config/jdbc-drivers/zentus-sqlite-license.txt</url>
+ </library>
+ <library>
+ <url>jar://$USER_HOME$/.IntelliJIdea11/config/jdbc-drivers/sqlitejdbc-v056.jar!/</url>
+ </library>
+ </libraries>
+ <table name="SCHEMA_MIGRATIONS" schema="" catalog="" type="TABLE">
+ <column name="version" sqlType="VARCHAR(255)" length="2000000000" precision="10" nullable="false" jdbcType="12" />
+ </table>
+ <table name="SQLITE_SEQUENCE" schema="" catalog="" type="TABLE">
+ <column name="name" sqlType="" length="2000000000" precision="10" nullable="true" jdbcType="12" />
+ <column name="seq" sqlType="" length="2000000000" precision="10" nullable="true" jdbcType="12" />
+ </table>
+ <table name="USERS" schema="" catalog="" type="TABLE">
+ <column name="id" sqlType="INTEGER" length="2000000000" precision="10" nullable="false" jdbcType="12" />
+ <column name="name" sqlType="VARCHAR(255)" length="2000000000" precision="10" nullable="true" jdbcType="12" />
+ <column name="email" sqlType="VARCHAR(255)" length="2000000000" precision="10" nullable="true" jdbcType="12" />
+ <column name="created_at" sqlType="DATETIME" length="2000000000" precision="10" nullable="false" jdbcType="12" />
+ <column name="updated_at" sqlType="DATETIME" length="2000000000" precision="10" nullable="false" jdbcType="12" />
+ <column name="password_digest" sqlType="VARCHAR(255)" length="2000000000" precision="10" nullable="true" jdbcType="12" />
+ <primary-key columns="id" />
+ </table>
+ </data-source>
+ <data-source source="LOCAL" name="Rails sample_app: test" product="" version="" jdbc-version="" driver-version="" uuid="db4d16c4-3304-4481-8192-ad8191569877">
+ <jdbc-driver>org.sqlite.JDBC</jdbc-driver>
+ <jdbc-url>jdbc:sqlite:/home/oli/Development/Rails/sample_app/db/test.sqlite3</jdbc-url>
+ <libraries>
+ <library>
+ <url>file://$USER_HOME$/.IntelliJIdea11/config/jdbc-drivers/zentus-sqlite-license.txt</url>
+ </library>
+ <library>
+ <url>jar://$USER_HOME$/.IntelliJIdea11/config/jdbc-drivers/sqlitejdbc-v056.jar!/</url>
+ </library>
+ </libraries>
+ </data-source>
+</component>
View
0  script/rails 100755 → 100644
File mode changed
View
11 spec/models/user_spec.rb
@@ -2,11 +2,12 @@
#
# Table name: users
#
-# id :integer not null, primary key
-# name :string(255)
-# email :string(255)
-# created_at :datetime not null
-# updated_at :datetime not null
+# id :integer not null, primary key
+# name :string(255)
+# email :string(255)
+# created_at :datetime not null
+# updated_at :datetime not null
+# password_digest :string(255)
#
require 'spec_helper'
View
8 spec/requests/user_pages_spec.rb
@@ -40,6 +40,14 @@
it "should create a user" do
expect { click_button "Sign up" }.to change(User, :count).by(1)
end
+
+ describe "after saving the user" do
+ before { click_button "Sign up" }
+ let(:user) { User.find_by_email('user@example.com') }
+
+ it { should have_selector('title', text: user.name) }
+ it { should have_selector('div.flash.success', text: 'Welcome') }
+ end
end
end
end
View
0  vendor/assets/stylesheets/blueprint/plugins/buttons/icons/cross.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  vendor/assets/stylesheets/blueprint/plugins/buttons/icons/key.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  vendor/assets/stylesheets/blueprint/plugins/buttons/icons/tick.png 100755 → 100644
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
0  vendor/assets/stylesheets/blueprint/src/grid.css 100755 → 100644
File mode changed
View
0  vendor/assets/stylesheets/blueprint/src/print.css 100755 → 100644
File mode changed
View
0  vendor/assets/stylesheets/blueprint/src/reset.css 100755 → 100644
File mode changed

No commit comments for this range

Something went wrong with that request. Please try again.