diff --git a/.gitignore b/.gitignore index 28a4c21..42f5ef5 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ # ignore al .DS_store files of MAC OSX .DS_Store + +public/system +.project diff --git a/Gemfile b/Gemfile index 3e9bf61..8e3bb0d 100644 --- a/Gemfile +++ b/Gemfile @@ -17,6 +17,7 @@ group :assets do end gem 'jquery-rails' +gem 'paperclip' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/Gemfile.lock b/Gemfile.lock index 264e4f9..d739548 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,7 @@ GEM ansi (1.4.1) arel (2.2.1) builder (3.0.0) + cocaine (0.2.0) coffee-rails (3.1.1) coffee-script (>= 2.2.0) railties (~> 3.1.0) @@ -40,20 +41,25 @@ GEM execjs coffee-script-source (1.1.3) erubis (2.7.0) - execjs (1.2.9) + execjs (1.2.11) multi_json (~> 1.0) hike (1.2.1) i18n (0.6.0) - jquery-rails (1.0.18) + jquery-rails (1.0.19) railties (~> 3.0) thor (~> 0.14) - json (1.6.1) + json (1.6.3) mail (2.3.0) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.17.2) - multi_json (1.0.3) + multi_json (1.0.4) + paperclip (2.4.5) + activerecord (>= 2.3.0) + activesupport (>= 2.3.2) + cocaine (>= 0.0.2) + mime-types polyglot (0.3.3) rack (1.3.5) rack-cache (1.1) @@ -82,7 +88,7 @@ GEM rake (0.9.2.2) rdoc (3.11) json (~> 1.4) - sass (3.1.10) + sass (3.1.11) sass-rails (3.1.5) actionpack (~> 3.1.0) railties (~> 3.1.0) @@ -92,7 +98,7 @@ GEM hike (~> 1.2) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sqlite3 (1.3.4) + sqlite3 (1.3.5) thor (0.14.6) tilt (1.3.3) treetop (1.4.10) @@ -111,6 +117,7 @@ PLATFORMS DEPENDENCIES coffee-rails (~> 3.1.1) jquery-rails + paperclip rails (= 3.1.3) sass-rails (~> 3.1.5) sqlite3 diff --git a/app/models/site.rb b/app/models/site.rb index dde788c..db8b534 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -1,3 +1,4 @@ class Site < ActiveRecord::Base belongs_to :type + has_attached_file :image end diff --git a/app/views/sites/_form.html.erb b/app/views/sites/_form.html.erb index 5f8becd..6324d86 100644 --- a/app/views/sites/_form.html.erb +++ b/app/views/sites/_form.html.erb @@ -36,8 +36,8 @@ <%= f.text_field :zoom %>
- <%= f.label :image_url %>
- <%= f.text_field :image_url %> + <%= f.label :image %>
+ <%= f.file_field :image %>
<%= f.submit %> diff --git a/app/views/sites/show.html.erb b/app/views/sites/show.html.erb index 244b974..c99f04d 100644 --- a/app/views/sites/show.html.erb +++ b/app/views/sites/show.html.erb @@ -2,7 +2,7 @@

<%= @site.type.name if @site.type %>

- <%= image_tag(@site.image_url, :class => 'site_image') %> + <%= image_tag(@site.image.url, :class => 'site_image') %>

<%= @site.name %>

diff --git a/db/migrate/20111207113324_add_image_columns_to_site.rb b/db/migrate/20111207113324_add_image_columns_to_site.rb new file mode 100644 index 0000000..d0bbf7f --- /dev/null +++ b/db/migrate/20111207113324_add_image_columns_to_site.rb @@ -0,0 +1,15 @@ +class AddImageColumnsToSite < ActiveRecord::Migration + def self.up + add_column :sites, :image_file_name, :string + add_column :sites, :image_content_type, :string + add_column :sites, :image_file_size, :integer + add_column :sites, :image_updated_at, :datetime + end + + def self.down + remove_column :sites, :image_file_name + remove_column :sites, :image_content_type + remove_column :sites, :image_file_size + remove_column :sites, :image_updated_at + end +end diff --git a/db/schema.rb b/db/schema.rb index 3717026..416ed62 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,18 +11,22 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20111127165324) do +ActiveRecord::Schema.define(:version => 20111207113324) do create_table "sites", :force => true do |t| t.string "name" t.text "description" t.integer "type_id" - t.decimal "latitude", :precision => 8, :scale => 6 - t.decimal "longitude", :precision => 8, :scale => 6 - t.decimal "zoom", :precision => 8, :scale => 6 + t.decimal "latitude", :precision => 8, :scale => 6 + t.decimal "longitude", :precision => 8, :scale => 6 + t.decimal "zoom", :precision => 8, :scale => 6 t.string "image_url" t.datetime "created_at" t.datetime "updated_at" + t.string "image_file_name" + t.string "image_content_type" + t.integer "image_file_size" + t.datetime "image_updated_at" end create_table "types", :force => true do |t| diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 9d9811a..0000000 --- a/public/index.html +++ /dev/null @@ -1,241 +0,0 @@ - - - - Ruby on Rails: Welcome aboard - - - - -
- - -
- - - - -
-

Getting started

-

Here’s how to get rolling:

- -
    -
  1. -

    Use rails generate to create your models and controllers

    -

    To see all available options, run it without parameters.

    -
  2. - -
  3. -

    Set up a default route and remove public/index.html

    -

    Routes are set up in config/routes.rb.

    -
  4. - -
  5. -

    Create your database

    -

    Run rake db:create to create your database. If you're not using SQLite (the default), edit config/database.yml with your username and password.

    -
  6. -
-
-
- - -
- -