erb

How do I get an image to line up with the text in Bootstrap nav list?

情到浓时终转凉″ 提交于 2019-12-12 00:24:13
问题 I'm trying to align an image with some text within a list item. I can't seem to get them to align though (see image). How can I get the text and image to align? I am using the default CSS files from Bootstrap and have no customized CSS for any of the classes or elements shown in my markup. Markup: <div class="col-md-3"> <ul class="nav"> <li><%= link_to "Connect", "#", class: "footer-heading" %></li> <li><%= image_tag "facebook.png", size: "32"%><%= link_to "Facebook", "url" %></li> <li><%=

.rb file reads one file but not the other - but they are right next to each other in the file structure…? (Errno::ENOENT)

瘦欲@ 提交于 2019-12-11 20:40:09
问题 I am doing the EventManager tutorial from Jumpstart. My problem is that it is not reading the 'form_letter.erb' file. My file structure is as follows: ~ event_manager (folder/located in root directory) lib (subfolder of event-manager) event_manager.rb (located in lib) event_attendees.cvs (located in event_manager) form_letter.erb (located in event_manager) form_letter.html (located in event_manager) full_event_attendees.cvs (located in event_manager) I have tried some of the ways I saw in

How do I make sure each post in the Post feed shown in the home page has all its comments displayed under it?

半城伤御伤魂 提交于 2019-12-11 14:33:53
问题 I have a Post model, and a Comment model that belongs to Post. I was able to display the Post in the home view corresponding to the home controller and home action and the User/show view. Thus, in the home and user views, the posts are listed in order of creation time. I was also able to have a post form in both the user and home views and a comment form in the home and user views. The problem arises when I try to display the comment underneath each displayed Post in the home and user views.

ERB view embedded in a Haml layout: what to do about whitespace now?

元气小坏坏 提交于 2019-12-11 13:57:30
问题 I have a Rails 3 app where the views are all done in Haml. However, there are some views coming from a required gems that are in ERB, and Haml is adding whitespace, and it's messing up textareas and such. (If you're not familiar with this aspect of haml, look here.) I'd rather not have to convert my layout to ERB, and because the gem is in ERB, all of the traditional Haml whitespace solutions don't help. So how do I get my textareas (and <pre>s etc) not to wrap? Anything smart I can do in my

Using a Form_for with an each loop

ⅰ亾dé卋堺 提交于 2019-12-11 12:08:24
问题 I'm trying to create a form in Rails that allows a user to select certain photos from a larger list using checkboxes. Unfortunately, I haven't found any similar examples and most posts out there are unhelpful. Any ideas on how to solve this? <div> <%= form_for :photos, url: trip_path, method: "PUT" do |f| %> <% @photos.each_with_index do |image, index|%> <img src="<%= image.url %>" ><br> <span> <%=image.caption%> | <%=image.lat %> | <%= image.long %> <%= f.hidden_field "url", :value => image

The Haml form tag includes nothing on Rails 3

霸气de小男生 提交于 2019-12-11 10:39:32
问题 I think there may be a bug in Haml? Or something I missed The form tag supposed to enclose the input element, but it doesn't. <form accept-charset="UTF-8" action="/remote_focus/kill_running_task" data-remote="true" method="get"></form> <tr> <td>... Where I expect it is <form accept-charset="UTF-8" action="/remote_focus/kill_running_task" data-remote="true" method="get"> <tr> <td>... </form> This is my haml file, iterate each task from an array, - @running_tasks.each do |running_task| = form

Chart.js line 2686 Error

旧城冷巷雨未停 提交于 2019-12-11 07:43:41
问题 I want lineChart of Chart.js in my sinatra application. But firefox console says `TypeError:this.scale is undefined(Chart.js:2686)` and, lineChart is not displayed.I wrote following code. @hello.erb <html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript"></script> <script src="Chartjs/Chart.js" type="text/javascript"></script> <script src="script.js" type="text/javascript"></script> </head> <body> <canvas id="line" height="450" width="600

Load a YAML file with variable in Ruby

巧了我就是萌 提交于 2019-12-11 07:33:14
问题 I'm building a chatbot and storing my 'replies' in a Yaml file below: # say_hello.yml - reply_type: text text: "Welcome <%= @user.first_name %>" - reply_type: delay duration: 2 - reply_type: text text: "We're here to help you learn more about something or another." - reply_type: delay duration: 2 In order to run the replies I use this method: def process @user = User.find(user_id) replies = YAML.load(ERB.new(File.read("app/bot/replies/say_hello.yml")).result) replies.each do |reply| # code

How to make html code in erb tag not escaped

佐手、 提交于 2019-12-11 05:21:26
问题 I have some simple erb code in one of my views in a rails project. <%= comment.body %> I'd like the html tags in the comment.body to be preserved as they have formatting information. I've verified that the text is saved in the database properly like <b>hello</b> However it turns out on the page to be <b>hello</b> not hello as I expect. How could this be? I'm not using <%= h to escape the html code. How do I make it not escaping? I'm using rails 3. Does this matter? 回答1: Rails 3 now

How do I undo Rails template generation in Haml?

笑着哭i 提交于 2019-12-11 02:32:34
问题 I installed a new gem to my Rails project - 'phrasing' - which has gem dependencies on multiple Haml gems. I need the gem (it is adding some phenomenal functionality to my project), and need the dependencies to be installed, but now when I run rails generate scaffold , all of the view templates are generated in Haml rather than ERB. I need views to continue to be generated in ERB. I reviewed several previous StackOverflow articles, but most focus on converting TO Haml, and the answers around