How to make URL on a PIC in Ruby On Rails? - html

I'm new to RoR so bear with me.
I have this forthcoming website open in Production Mode here:
http://88.112.168.70/
I have there 2 FB logo pics at the end of every sub-page (the GREEN area) and I honestly have no idea on how to insert URL LINKS on those logos.
The FB logos and the whole ending section currently comes from a LAYOUT file, of whichs' code is below:
<tr>
<td class="otsikko-ala">
<p class="small">
<%=image_tag("facebook_logo-green.png", alt: "Tommi Tiihonen", :class=> "fb", :align=> "right")%>
<%=image_tag("facebook_logo.png", alt: "Tommi Tiihonen", :class=> "fb", :align=> "right")%>
<strong>Web-Studio</strong>
<br>
The World at Your Fingertips
</p>
</td>
So if I would like to have an URL on both images to, say, URL: http://www.com, then how would I do that? I ALSO don't want any borders on the URLed FB logos. BUT I do want to have a Title Tag and an Alt Tag on those.
AND:::: I want to have the TARGET frame value as "_new".
Please if it isn't too much asked, could you put the whole tag here - not only the explanation.
Thanks in advance!
-Tommi

If you want to make a link out of an image, just do this:
<%= link_to 'http://www.com', target: "_blank", alt: "my alt here", title: "my title here" do
<%= image_tag 'facebook_logo.png' %>
<% end %>

Related

Anchor tags with rails 4 working weird

Ok so I've encountered a very very weird problem that has got me staying up late but I finally figured out whats wrong however, the solution is not ideal and I would like to know what is happening. Better yet, how to fix it.
I have a page seperated with many div tags with the id class. I have other pages that are done the same way with no problems at all when I try to link to a particular section of a page from another page with the following methods. However, the problem occurs when the page Im linking to has not enough content.. but still is at least scrollable length.. When clicking on the links that way, instead of moving to the desired section, it just moves towards the bottom.
For instance if you clicked on this website, http://aquaticshelp.com/aquascape/getting-started#aquascape-main-plants and clicked on the "Preparing your plant section" you will see what I mean. This is a very undesirable behavior and Im not sure where to go from here.
<%= link_to 'Section 1', route_path(anchor: "section-1"), class: "h4" %>
<div id="section-1">
</div>
<div id="section-2">
</div>
<div id="section-3">
</div>
EDIT: Added some screen shots for clarity of question
Below is where you click and contains the following code
<%= link_to aquascape_plants_prep_path(anchor: "aquascape-plants-prep-intro") do %>
<%= image_tag("aquascaping/start/plant_prep_img.jpg", size:"140x140", class: "img-circle center-block")%>
<%= link_to 'Preparing the Plants', aquascape_plants_prep_path(anchor: "aquascape-plants-prep-intro"), class: "h4" %>
<% end %>
The following is where it directs me to regardless of the anchor tag
Where I want it to go, and it does if I click on the following
<%= link_to 'Intro', "#aquascape-plants-prep-intro" %>

How to add an html image in select dropdown options?

I want to add the user's avatar next to the name in options:
<%= f.select(:user_id,
#users.map{|s|[s.lastname+', '+s.firstname, s.id]},
{},
:class => "ui fluid dropdown"
) %>
And If possible, I want also to enter some html in it:
<%= #user.avatar.blank? ?
image_tag("no-image.png", alt: "noimage", class: "ui small rounded image") :
image_tag(#user.avatar.url(:thumb), alt: "user-image", class: "ui small rounded image")
%>
How is it possible in Rails 4?
EDIT: Another thing I want to do is to display a circle with a color on the front of the text. Let's say I want a green dot in front of active users and a red on inactive ones. This is going to be implemented with CSS and I've seen it a lot of times in various websites, but I am not sure how to do it.

How to hide an entire DIV in a rails project if no data is being passed to it from the CMS?

Using Refinery CMS to create product pages in our prototype. An admin can add a link to the main product page, and it will display similar to
Product Links
www.example.com/product/1
www.example.com/product/2
here is a screenshot of how it currently is being displayed
However, there will not always be a case when the ink is added. And this looks weird to have that field but no links in there because every element has margin-bottom:30px;
So my question is how do I make the element not show up at all if nothing is passed to it. Here is the code for the element:
HTML
<div class="contentPageElement">
<h3>Product Links</h3>
<%= link_to #discussion.link.to_s, #discussion.link %>
</div>
you can either put it in helper,or do something like this.
<% unless #discussion.link.empty? %>
<div class="contentPageElement">
<h3>Product Links</h3>
<%= link_to #discussion.link.to_s, #discussion.link %>
</div>
<% end %>
I think this is what you're looking for: http://apidock.com/rails/ActionView/Helpers/UrlHelper/link_to_unless

Photos I upload to my ruby-on-rails server look bad

showing bad quality image on ruby on rails websit
ruby script:
<div align="center">
<p align="center">
<%= if property.images[0] then link_to image_tag
(property.images[0].image.url('700x525', :jpg)),
user_property_image_path(user, :id => property.images[0],
:property_id => property) end -%>
</p>
</div>
hot to improve the photo quality?
The loaded photo is 600x400px, I thought the website was displaying it as 533x354px, but it's not actually scaling it, it's just showing what's (probably) inside your div, and leaves the overflow invisible.
The photos I can see are actually low quality, are those the original ones? (If so, there's not much to do here, unfortunately!)

Go to particular div in rails 3

I have these two codes lines in subnativation.
<%= link_to "Basic Info", request.request_uri + "#users_details"%>
<%= link_to "Photos", request.request_uri + "#users_photos"%>
==>
/users/1#users_details
/users/1#users_photos
Its not navigating to that particular Div.
PS: users_details and users_photo are Id's of two different div's
#users_details will navigate to <a name='users_details'></a> and #users_photos to <a href='users_photos'></a> somewhere in your HTML.
So put before your users_details div this: <a name='users_details'></a> and enjoy!
Try writing your links in a style that makes it more obvious where you are actually trying to go: something like <%= link_to "Basic Info", users_path(#user, :anchor => 'user_details') %>. This will create a link to the users#show page but also include the anchor to go to any block level element with the id of user_details.