#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    1
    Rep Power
    0

    Unhappy 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!!
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2004
    Location
    Constant Limbo
    Posts
    989
    Rep Power
    363
    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
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    3
    Rep Power
    0
    Is there advantages of Ruby compared to php? Don't know would it be profitable for me to learn it
  6. #4
  7. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,607
    Rep Power
    4247
    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

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2010
    Location
    San Jose
    Posts
    20
    Rep 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.
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2010
    Location
    Toronto, Canada
    Posts
    5
    Rep 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.

    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!

IMN logo majestic logo threadwatch logo seochat tools logo