Created
November 16, 2010 15:19
-
-
Save neotericdesign/701921 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| <%# add this field within the form: %> | |
| <div class='field'> | |
| <%= f.label :image -%> | |
| <%= render :partial => "/shared/admin/image_picker", :locals => { | |
| :f => f, | |
| :field => :image_id, | |
| :image => @engine.image, # obviously change the variable for your purposes | |
| :toggle_image_display => false | |
| } %> | |
| </div> | |
| <%# this should be all you have to do %> |
This file contains hidden or 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
| # $: rails g migration AddImageIdToPages image_id:integer | |
| # produces: | |
| class AddImageIdToPages < ActiveRecord::Migration | |
| def self.up | |
| add_column :pages, :image_id, :integer | |
| end | |
| def self.down | |
| remove_column :pages, :image_id | |
| end | |
| end |
This file contains hidden or 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 Image < ActiveRecord::Base | |
| #... | |
| has_many :pages | |
| #... | |
| end |
This file contains hidden or 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 Page < ActiveRecord::Base | |
| #... | |
| belongs_to :image | |
| #... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment