Rails - Unable to add image within style="background-image:url (' ') from database












0















I'm new to rails and stack over flow, I would be grateful to you all if I can guided here.



I'm developing a test site which is like a personal blog just to add portfolio for one user.



I have a scaffold "Dashboard" which is used to update homepage information of the website such as Titles, Banners, About Me etc.



All text of from the database is coming on the homepage perfectly fine.



However, banner images are not coming appropriately as per the theme style.



My problem - When the banner is added the text above the banner gets hidden.



Below is my code for your kind reference, I'm sure I'm making some mistake in this line



<div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


However, unable to rectify it yet.



Original line of code:



<div class="swiper-slide cover-background" style="background-image:url('http://placehold.it/1920x1080');">


any help or suggestion would be great.



Complete Code for reference



<% @dashboards.order('created_at ASC').limit(1).each do |dashboard| %>
<section class="no-padding main-slider height-100 mobile-height wow fadeIn">
<div class="swiper-full-screen swiper-container height-100 width-100 white-move">
<div class="swiper-wrapper">
<!-- start slider item -->
<div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">
<div class="opacity-extra-medium bg-black"></div>
<div class="container position-relative full-screen">
<div class="slider-typography text-center">
<div class="slider-text-middle-main">
<div class="slider-text-middle">
<div class="alt-font text-white text-uppercase font-weight-700 letter-spacing-minus-3 title-extra-large margin-two-bottom width-60 center-col md-width-80 sm-margin-four-bottom xs-width-90 xs-margin-25px-bottom xs-letter-spacing-0"><%= dashboard.name %></div>
<div class="btn-dual">
<a href="about-us-modern.html" class="btn btn-transparent-white btn-small xs-margin-two-all">About Company</a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- end slider item -->
<% end %>









share|improve this question



























    0















    I'm new to rails and stack over flow, I would be grateful to you all if I can guided here.



    I'm developing a test site which is like a personal blog just to add portfolio for one user.



    I have a scaffold "Dashboard" which is used to update homepage information of the website such as Titles, Banners, About Me etc.



    All text of from the database is coming on the homepage perfectly fine.



    However, banner images are not coming appropriately as per the theme style.



    My problem - When the banner is added the text above the banner gets hidden.



    Below is my code for your kind reference, I'm sure I'm making some mistake in this line



    <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


    However, unable to rectify it yet.



    Original line of code:



    <div class="swiper-slide cover-background" style="background-image:url('http://placehold.it/1920x1080');">


    any help or suggestion would be great.



    Complete Code for reference



    <% @dashboards.order('created_at ASC').limit(1).each do |dashboard| %>
    <section class="no-padding main-slider height-100 mobile-height wow fadeIn">
    <div class="swiper-full-screen swiper-container height-100 width-100 white-move">
    <div class="swiper-wrapper">
    <!-- start slider item -->
    <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">
    <div class="opacity-extra-medium bg-black"></div>
    <div class="container position-relative full-screen">
    <div class="slider-typography text-center">
    <div class="slider-text-middle-main">
    <div class="slider-text-middle">
    <div class="alt-font text-white text-uppercase font-weight-700 letter-spacing-minus-3 title-extra-large margin-two-bottom width-60 center-col md-width-80 sm-margin-four-bottom xs-width-90 xs-margin-25px-bottom xs-letter-spacing-0"><%= dashboard.name %></div>
    <div class="btn-dual">
    <a href="about-us-modern.html" class="btn btn-transparent-white btn-small xs-margin-two-all">About Company</a>
    </div>
    </div>
    </div>
    </div>
    </div>
    </div>
    <!-- end slider item -->
    <% end %>









    share|improve this question

























      0












      0








      0








      I'm new to rails and stack over flow, I would be grateful to you all if I can guided here.



      I'm developing a test site which is like a personal blog just to add portfolio for one user.



      I have a scaffold "Dashboard" which is used to update homepage information of the website such as Titles, Banners, About Me etc.



      All text of from the database is coming on the homepage perfectly fine.



      However, banner images are not coming appropriately as per the theme style.



      My problem - When the banner is added the text above the banner gets hidden.



      Below is my code for your kind reference, I'm sure I'm making some mistake in this line



      <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


      However, unable to rectify it yet.



      Original line of code:



      <div class="swiper-slide cover-background" style="background-image:url('http://placehold.it/1920x1080');">


      any help or suggestion would be great.



      Complete Code for reference



      <% @dashboards.order('created_at ASC').limit(1).each do |dashboard| %>
      <section class="no-padding main-slider height-100 mobile-height wow fadeIn">
      <div class="swiper-full-screen swiper-container height-100 width-100 white-move">
      <div class="swiper-wrapper">
      <!-- start slider item -->
      <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">
      <div class="opacity-extra-medium bg-black"></div>
      <div class="container position-relative full-screen">
      <div class="slider-typography text-center">
      <div class="slider-text-middle-main">
      <div class="slider-text-middle">
      <div class="alt-font text-white text-uppercase font-weight-700 letter-spacing-minus-3 title-extra-large margin-two-bottom width-60 center-col md-width-80 sm-margin-four-bottom xs-width-90 xs-margin-25px-bottom xs-letter-spacing-0"><%= dashboard.name %></div>
      <div class="btn-dual">
      <a href="about-us-modern.html" class="btn btn-transparent-white btn-small xs-margin-two-all">About Company</a>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      <!-- end slider item -->
      <% end %>









      share|improve this question














      I'm new to rails and stack over flow, I would be grateful to you all if I can guided here.



      I'm developing a test site which is like a personal blog just to add portfolio for one user.



      I have a scaffold "Dashboard" which is used to update homepage information of the website such as Titles, Banners, About Me etc.



      All text of from the database is coming on the homepage perfectly fine.



      However, banner images are not coming appropriately as per the theme style.



      My problem - When the banner is added the text above the banner gets hidden.



      Below is my code for your kind reference, I'm sure I'm making some mistake in this line



      <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


      However, unable to rectify it yet.



      Original line of code:



      <div class="swiper-slide cover-background" style="background-image:url('http://placehold.it/1920x1080');">


      any help or suggestion would be great.



      Complete Code for reference



      <% @dashboards.order('created_at ASC').limit(1).each do |dashboard| %>
      <section class="no-padding main-slider height-100 mobile-height wow fadeIn">
      <div class="swiper-full-screen swiper-container height-100 width-100 white-move">
      <div class="swiper-wrapper">
      <!-- start slider item -->
      <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">
      <div class="opacity-extra-medium bg-black"></div>
      <div class="container position-relative full-screen">
      <div class="slider-typography text-center">
      <div class="slider-text-middle-main">
      <div class="slider-text-middle">
      <div class="alt-font text-white text-uppercase font-weight-700 letter-spacing-minus-3 title-extra-large margin-two-bottom width-60 center-col md-width-80 sm-margin-four-bottom xs-width-90 xs-margin-25px-bottom xs-letter-spacing-0"><%= dashboard.name %></div>
      <div class="btn-dual">
      <a href="about-us-modern.html" class="btn btn-transparent-white btn-small xs-margin-two-all">About Company</a>
      </div>
      </div>
      </div>
      </div>
      </div>
      </div>
      <!-- end slider item -->
      <% end %>






      html css ruby-on-rails






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 3 at 8:59









      Peeyush VermaPeeyush Verma

      32




      32
























          1 Answer
          1






          active

          oldest

          votes


















          2














          Using the image_tag helper will generate and return a complete a HTML tag like <a src="foo/bar.jpg" /> not just the URL which you need in your example.



          Just change this line



          <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


          to



          <div class="swiper-slide cover-background" style="background-image:url('<%= dashboard.banner1.url %>');">





          share|improve this answer
























          • Awesome thanks a lot. :)

            – Peeyush Verma
            Jan 3 at 9:10











          • @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

            – Jake
            Jan 3 at 12:09











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019061%2frails-unable-to-add-image-within-style-background-imageurl-from-databa%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Using the image_tag helper will generate and return a complete a HTML tag like <a src="foo/bar.jpg" /> not just the URL which you need in your example.



          Just change this line



          <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


          to



          <div class="swiper-slide cover-background" style="background-image:url('<%= dashboard.banner1.url %>');">





          share|improve this answer
























          • Awesome thanks a lot. :)

            – Peeyush Verma
            Jan 3 at 9:10











          • @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

            – Jake
            Jan 3 at 12:09
















          2














          Using the image_tag helper will generate and return a complete a HTML tag like <a src="foo/bar.jpg" /> not just the URL which you need in your example.



          Just change this line



          <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


          to



          <div class="swiper-slide cover-background" style="background-image:url('<%= dashboard.banner1.url %>');">





          share|improve this answer
























          • Awesome thanks a lot. :)

            – Peeyush Verma
            Jan 3 at 9:10











          • @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

            – Jake
            Jan 3 at 12:09














          2












          2








          2







          Using the image_tag helper will generate and return a complete a HTML tag like <a src="foo/bar.jpg" /> not just the URL which you need in your example.



          Just change this line



          <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


          to



          <div class="swiper-slide cover-background" style="background-image:url('<%= dashboard.banner1.url %>');">





          share|improve this answer













          Using the image_tag helper will generate and return a complete a HTML tag like <a src="foo/bar.jpg" /> not just the URL which you need in your example.



          Just change this line



          <div class="swiper-slide cover-background" style="background-image:url('<%= image_tag dashboard.banner1.url %>');">


          to



          <div class="swiper-slide cover-background" style="background-image:url('<%= dashboard.banner1.url %>');">






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 3 at 9:08









          spickermannspickermann

          61.2k75880




          61.2k75880













          • Awesome thanks a lot. :)

            – Peeyush Verma
            Jan 3 at 9:10











          • @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

            – Jake
            Jan 3 at 12:09



















          • Awesome thanks a lot. :)

            – Peeyush Verma
            Jan 3 at 9:10











          • @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

            – Jake
            Jan 3 at 12:09

















          Awesome thanks a lot. :)

          – Peeyush Verma
          Jan 3 at 9:10





          Awesome thanks a lot. :)

          – Peeyush Verma
          Jan 3 at 9:10













          @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

          – Jake
          Jan 3 at 12:09





          @PeeyushVerma Don't forget to accept the answer if it worked, thank you!

          – Jake
          Jan 3 at 12:09




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54019061%2frails-unable-to-add-image-within-style-background-imageurl-from-databa%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Mossoró

          Error while reading .h5 file using the rhdf5 package in R

          Pushsharp Apns notification error: 'InvalidToken'