Created
April 20, 2012 07:58
-
-
Save Soldo/2427002 to your computer and use it in GitHub Desktop.
facebook like - blog post
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
| This is the code included in <head> section: | |
| <% require 'nokogiri' %> | |
| <% frag = Nokogiri::HTML.fragment( 'hello world' ) %> (actually here suppose to go @post.body.html_safe) | |
| <% first_img_src = frag.at_css('img')['src'] %> | |
| <% first_p_text = frag.at_css('p').text %> | |
| <meta property="og:title" content="Ovdje ide naslov" /> | |
| <meta property="og:type" content="sport" /> | |
| <meta property="og:url" content="http://kbk-siroki.herokuapp.com" /> | |
| <meta property="og:image" content=<%= first_img_src %> /> | |
| <meta property="og:description" content=<%= first_p_text %> /> | |
| <meta property="og:site_name" content="Kickboxing Klub Siroki Brijeg" /> | |
| and I'm getting this error message: | |
| "no such file to load -- nokogiri" | |
| When I remove 1. line <% require 'nokogiri' %> i get this error: | |
| "uninitialized constant ActionView::CompiledTemplates::Nokogiri" | |
| . | |
| . | |
| . | |
| So, I did this: | |
| [kickboxing (master)]$ rake refinery:override model=refinery/blog/post | |
| Copied model file to app/models/refinery/blog/post.rb | |
| And i pasted this code in between friendly_id_source and self << class | |
| def friendly_id_source | |
| custom_url.present? ? custom_url : title | |
| end | |
| def face_book_img | |
| require 'nokogiri' | |
| frag = Nokogiri::HTML.fragment( self.body ) | |
| first_img_src = frag.at_css('img')['src'] | |
| end | |
| class << self | |
| def by_archive(date) | |
| where(:published_at => date.beginning_of_month..date.end_of_month) | |
| end | |
| def by_year(date) | |
| Then, in the <head> section I changed this line: | |
| <meta property="og:image" content=face_book_img /> | |
| But when I clicked on LIKE button I didn't get a picture from teaser |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment