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

    Join Date
    Jun 2012
    Posts
    9
    Rep Power
    0

    How to add a word limit for ruby script?


    my original script is:
    <%= property.advert_heading ? link_to(property.advert_heading, user_property_path(user,property)): ' '-%>

    I want to add a script " length =>120" to limit the text to 120. how should I do it please
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    112
    Rep Power
    10
    I assume that you want something like this:

    Code:
    <%= property.advert_heading ? link_to(property.advert_heading[0..120], user_property_path(user,property)): ' '-%>
    @ PresentSoft Technologies Pvt. Ltd., a software development firm in Goa - India, we develop scalable applications using on Ruby on Rails and Android.

    My blog @ AnayKamat.com
  4. #3
  5. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,957
    Rep Power
    1045
    Why do you dig out all old threads and post a complete solution? Bored?
    The 6 worst sins of security ē How to (properly) access a MySQL database with PHP

    Why canít I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2005
    Posts
    112
    Rep Power
    10
    Originally Posted by Jacques1
    Why do you dig out all old threads and post a complete solution? Bored?
    Simple, even if the post is old, people do end up referring it through search engines. Thus, it is a responsibility to post the answer in case you know it. Somebody will definitely benefit from it.
    @ PresentSoft Technologies Pvt. Ltd., a software development firm in Goa - India, we develop scalable applications using on Ruby on Rails and Android.

    My blog @ AnayKamat.com

IMN logo majestic logo threadwatch logo seochat tools logo