The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> Ruby Programming
|
Know nothing about Ruby, can't modify files on a website (index.html.erb??!)
Discuss Know nothing about Ruby, can't modify files on a website (index.html.erb??!) in the Ruby Programming forum on Dev Shed. Know nothing about Ruby, can't modify files on a website (index.html.erb??!) Ruby and Ruby on Rails programming forum covering Ruby Tips and Tricks, Best Practices, and agile development with Ruby on Rails.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

September 15th, 2010, 09:47 PM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 1
Time spent in forums: 12 m 5 sec
Reputation Power: 0
|
|
Know nothing about Ruby, can't modify files on a website (index.html.erb??!)
Hello,
I'm really confused. I know basic html, unix, php, few other things.
I need to add META tags for a friend, different tags on every page of his site.
Got into his FTP and his directory structure just boggled me.
He runs nginx.
After much searching I found all the files I needed with .erb extensions appended to them. There's a gems folder, so I'm guessing Ruby is involved.
When I go to ..../sitename_main/stable/app/views/main/ (damn that's deep in the tree!)
I find files like index.html.erb.
So I decided to try to edit these to add meta tags.
Didn't work.. the <title> and <head> area's of the page aren't changeable from there, the index.html.erb file just starts with:
Code:
<body id="index">
<div class="full_page">
<div class="main_cont">
<div class="top_banner">
<%= render :partial => "main/top_ban" %>
</div>
<div class="index_images">
<img id="ban_1" src="images/index_banner.jpg" width="936px" height="290px" style="opacity: 0;"/>
<img id="ban_2" src="images/index_banner2.jpg" width="936px" height="290px" style="opacity: 0;"/>
<img id="ban_3" src="images/index_banner3.jpg" width="936px" height="290px" style="opacity: 0;"/>
<img id="ban_4" src="images/index_banner4.jpg" width="936px" height="290px" style="opacity: 0;"/>
<img id="ban_5" src="images/index_banner5.jpg" width="936px" height="290px" style="opacity: 0;"/>
</div>
<div class="top_menu">
........
........
........
How to I add meta tags (and titles) to each individual page?
Any help would be appreciated, thanks guys!!
|

September 16th, 2010, 05:58 AM
|
|
Contributing User
|
|
Join Date: Jan 2004
Location: Constant Limbo
|
|
This sounds a lot like a Rails setup. Rails uses ERB (Ruby templating mechanism) extensively.
If you need to edit the head/title portions of the eventual file maybe you can look for the inclusion of that file you show in other sources. This is entirely a shot in the dark as I am unaware of your setup and dont know diddly about the inner workings of Rails. Consider the following
Code:
$ cat foo.rb
#!/usr/bin/env ruby
puts "In Foo"
require 'bar.rb'
$ cat bar.rb
puts "Bar included"
$ ruby foo.rb
In Foo
Bar included
So you might have some success if you grep for something like
Code:
egrep -Rn "require index.html.erb"
Though, you may have more consistent reqults if you just read up on how Rails works and edit things the ways they suggest 
__________________
True happiness is not getting what you want, it's wanting what you've already got.
My Blog
|

September 21st, 2010, 04:10 AM
|
|
Registered User
|
|
Join Date: Sep 2010
Posts: 3
Time spent in forums: 29 m 36 sec
Reputation Power: 0
|
|
Is there advantages of Ruby compared to php? Don't know would it be profitable for me to learn it 
|

September 21st, 2010, 09:23 AM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Most likely, the code is using a template. What you need to do is look here:
/sitename_main/stable/app/views/layouts
and see if there is a file here that has <html><head>...
Then, all you have to do is modify this file and make it accept parameters from the controller:
e.g.
Code:
<title><%= @title %> - My Site Name</title>
<meta name="keywords" content="<%= @meta_keywords %>" />
<meta name="description" content="<%= @meta_description %>" />
and then modify your controller file (which should be /sitename_main/stable/app/controllers/main.rb) and add the following into the different functions here:
Code:
@title = "Custom title"
@meta_keywords = "Something, something else"
@meta_description = "Fee fie fo fum"
You can modify the controller so that @title, @meta_keywords and @meta_description have a default value and then override in specific functions.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|

October 13th, 2010, 09:07 AM
|
|
Registered User
|
|
Join Date: May 2010
Location: San Jose
Posts: 21
Time spent in forums: 4 h 3 m 51 sec
Reputation Power: 0
|
|
|
ruby is a pure object oriented language
As compared to php, ruby is a pure Object oriented language. ruby possesses many metaprogramming attributes which can be used in rails development.
|

October 15th, 2010, 05:51 PM
|
|
Registered User
|
|
Join Date: Oct 2010
Location: Toronto, Canada
Posts: 5
Time spent in forums: 1 h 11 m 7 sec
Reputation Power: 0
|
|
Hello! I had to re-register with a new username, as I was having problems with my old email account., I'm the same user who started this thread though.
Quote: | Originally Posted by Scorpions4ever Most likely, the code is using a template. What you need to do is look here:
/sitename_main/stable/app/views/layouts
and see if there is a file here that has <html><head>...
Then, all you have to do is modify this file and make it accept parameters from the controller:
e.g.
Code:
<title><%= @title %> - My Site Name</title>
<meta name="keywords" content="<%= @meta_keywords %>" />
<meta name="description" content="<%= @meta_description %>" />
and then modify your controller file (which should be /sitename_main/stable/app/controllers/main.rb) and add the following into the different functions here:
Code:
@title = "Custom title"
@meta_keywords = "Something, something else"
@meta_description = "Fee fie fo fum"
You can modify the controller so that @title, @meta_keywords and @meta_description have a default value and then override in specific functions. |
First of all, thanks SO much for the response.
When I go to ...sitename/stable/app/views/layouts
There is one file in the subdirectory, it is entitled application.html.erb.
Is this the file I'm looking for?
When I try to download it, all I get is an empty file..
Could it be that I just don't have access permissions or should I be taking a different course of action?
Thanks again!
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|