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 Post < ActiveRecord::Base | |
require 'RedCloth' | |
has_many :photos | |
liquid_methods :post, :photo, :photos, :posts #Testing everything | |
#Works, but I want to be able to call it dynamicly in a textarea. | |
#SO I can use textile !{% picture 2 %}. | |
def pic(pos) | |
photos[pos.to_i].image.url(:medium) | |
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
class Post < ActiveRecord::Base | |
require 'RedCloth' | |
has_many :photos | |
liquid_methods :post, :photo, :photos, :posts #Testing everything | |
#Works, but I want to be able to call it dynamicly in a textarea. | |
#SO I can use textile !{% picture 2 %}. | |
def pic(pos) | |
photos[pos.to_i].image.url(:medium) | |
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
class Post < ActiveRecord::Base | |
require 'RedCloth' | |
has_many :photos | |
liquid_methods :post, :photo, :photos, :posts #Testing everything | |
#Works, but I want to be able to call it dynamicly in a textarea. | |
#SO I can use textile !{% picture 2 %}. | |
def pic(pos) | |
photos[pos.to_i].image.url(:medium) | |
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
#Post.rb | |
def picture(pos=0) | |
photos[pos.to_i].image.url(:medium) | |
end | |
#Index.erb.html I NEED post.picture to get AN ARGUMENT from 'picture' | |
<%= textilize(Liquid::Template.parse(post.content).render('picture' => post.picture)) %> |
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 PhotoPicker # < Liquid::Tag | |
def initialize(tag_name, photo_pos, tokens) | |
super | |
@photo = photo_pos.to_i | |
end | |
def render(context) | |
#photos[@photo].image.url(:medium) | |
context['post'][@photo].image.url(:medium) | |
#rand(@photo) |
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.fields_for :photos, :html => { :multipart => true } do |picture| %> | |
<%= picture.label :image %> | |
<%= picture.file_field :image %> | |
<% 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
<h1>New post</h1> | |
<% @post.photos.build if @post.photos.empty? %> | |
<% form_for(@post) do |f| %> | |
<%= f.error_messages %> | |
<p> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</p> | |
<p> |
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
<h1>New post</h1> | |
<% form_for(@post) do |f| %> | |
<%= f.error_messages %> | |
<p> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</p> | |
<p> | |
<%= f.label :content %><br /> |
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
<h1>New post</h1> | |
<% form_for(@post) do |f| %> | |
<%= f.error_messages %> | |
<p> | |
<%= f.label :name %><br /> | |
<%= f.text_field :name %> | |
</p> | |
<p> | |
<%= f.label :content %><br /> |