Questions tagged [erb]
ERB is a simple templating system for Ruby, embedding code in any plain-text document. It is often used for HTML generation in web frameworks (such as Ruby on Rails).
2,635
questions
1
vote
1
answer
55
views
Rails: Form that sets up default values for an object?
Say I have an object that has some attributes with default values. I set up the default values for these attributes at a model level like so...
after_initialize :set_defaults
def set_defaults
...
1
vote
0
answers
33
views
Why Tailwind CSS doesn't works with public/*.html files in my Ruby on Rails project
I'm using Tailwind CSS for my Ruby on Rails project, the CSS works fine with all the layouts in views but it doesn't works with public/*.html files in my project.
I have a 404.html page and a 500.html ...
0
votes
0
answers
44
views
How to run ./bin/dev for Ruby on Rails from WSL
I cloned a repository which uses /bin/dev to update the changes in the code (tailwind css) dynamically without the need of asssets:recompilation.
As I am using Windows, in order to run ./bin/dev, I ...
1
vote
1
answer
107
views
Why do Ruby ERB if statements set variables to nil?
I'm using ERB to generate a set of instructions with location data, and want to accept an offset in my input. When I try to check if that offset is present however, it sets it's value to nil. If ...
0
votes
1
answer
20
views
rails - initialising a form value from parameter does not work?
I am rendering a simple form with a number field, trying to set the initial value of the field with a variable. If I use a constant in the ERB template it renders - if I set the value from a variable, ...
1
vote
2
answers
69
views
Rails Associated Child Model
I am trying to follow the rails getting started guide to set up my project, but am running into an issue with setting up the nested models/controllers/views.
I have Activity model and Refusal model, ...
1
vote
1
answer
60
views
image_tag not returning image using url in service
module FileService
class LetterGenerator
def initialize(user)
@user = user
end
def process
WickedPdf.new.pdf_from_string(
ApplicationController.new.render_to_string(
...
0
votes
0
answers
16
views
Embedding File Path Explorer in Open OnDemand Passenger App
How to Embed File Path Explorer in Open OnDemand Passenger App
I'm developing an app using Open OnDemand that allows users to submit their Gaussian scripts to SLURM via a custom wrapper we use at our ...
0
votes
1
answer
39
views
Bootstrap + Simple Form in Rails validation fails BUT fields are not turning red
I researched and there is another issue with the same title but the solution doesn't help/apply.
Issue: Fields in simple_form don't turn red despite validations are failing on saving the object - in ...
0
votes
1
answer
26
views
Chef : using search method in a template file
I'm in a Chef template file, to deploy a bash script.
I need to retrieve the fqdn of another node, that has a specific role. I tried the following :
#!/bin/bash
[...]
<%- master_servers = search(:...
0
votes
0
answers
47
views
Evaluate YAML elements with ERB syntax
I have a YAML which includes some ERB blocks:
---
- id: "1"
pre: |
<%
a = rand(2..20)
b = rand(1..20)
%>
sentence: "The result of <%=a%> + <%=b%&...
1
vote
1
answer
55
views
When using a Hash as a ERB templates, ruby complains about "encoding"
Simply to that
require 'erb'
a = "això és una merda <%=rand(1..20)%>"
c = {"id" => "això és una merda <%=rand(1..10)%>"}
If you run ERB.new(a).result, ...
0
votes
0
answers
65
views
how to link image?
I use Active Storage and Active Text. When I paste text and pictures in text_area, it create html like this:
<div class="trix-content">
<div>text1<action-text-...
0
votes
0
answers
43
views
Ruby on Rails 7: Validate collection_check_boxes array
In Rails, I have a model called Post with a field called columns. The user can select which columns are to be displayed. I do this using the following line of code in my form:
<%= form....
0
votes
0
answers
118
views
Call function from .js file in .js.erb file in Rails 7
So I am following this tutorial https://www.freecodecamp.org/news/lets-create-an-intermediate-level-ruby-on-rails-application-d7c6e997c63f/ and although many of the technologies used in it are ...