• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Embed video URL in rails application

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a doubt which might be silly for experience Rails developers.
I am creating an application which is suppose to embed a video player with URL passed to it.
So while displaying i.e in XXX.html.erb file i am writting below code. Now problem is @movie.trailer is my variable in ruby code which has URL value . I want the embedded video to load with URL given by this variable value. Any suggestion how am i suppose to place the value of Ruby variable(@movie.trailer) in <embed src="variable_value"> part.

Note :- This code is working perfectly fine if i statically give value of URL.
Please help
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The double quotes is telling Ruby that it is a string so what you are probably getting for src is literally "<% @movie.trailer %>". Try "#{<% @movie.trailer %>}" and make sure that @movie.trailer is returning a string, or just remove the double quotes. You could also place a method in the helper module to generate the string in the correct format.


If you want the results of the code to display you need <%= %>, but I don't think that takes care of the string concatenation.
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to do <%= @movie.trailer %> with the equals sign.

<% @movie.trailer %> without equals will evaluate the expression but will not render to the page.
I have gone to look for myself. If I should return before I get back, keep me here with this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic