Questions tagged [erb]

0

votes
2

answer
68

Views

Ruby DSL used across multiple <% %> tags or multiple lines

I am writing a helper DSL to make it easier to craft a nice menu ui within a view. The view's erb is producing an error undefined method 'safe_append=' for nil:NilClass when I break the block across multiple erb tags but it works fine if I stick it in one tag. I want to understand why -- it should...
Michael K Madison
1

votes
0

answer
151

Views

Ruby on Rails ERB Form for a Hash or field in a Postgres Hstore

in my ruby on rails project, I am using a Postgres hstore field called plugin_settings to store a hash of all my plugin settings dynamically. This way if a new plugin in written, no migrations need to be written in order to save the plugin settings on my ActiveRecord object. The hash is currently Pl...
Scott B
1

votes
1

answer
449

Views

Bootstrap dropdown not working in some views

I am struggling to get my dropdown menu to function properly. I pulled the template for the dropdown straight from the Twitter Bootstrap guide(v3) and tweaked it for my purposes. The app is built in Sinatra, and the code for the dropdown resides in my layout view. The menu works properly from any vi...
C. Boujoukos
1

votes
0

answer
82

Views

Padrino and sequel nested attributes form

I am trying to make a form for storing data hierarchy through the associations. My structure of database is meta - ID (PK) version - meta_id (FK of meta) - ID (PK) - lang (FK from lang ...) - .... data - ID (FK of version) I need to store multiple language content under one ID. Models are class Me...
Levi
1

votes
1

answer
319

Views

Looping through nested yaml data in .erb file

I'm not overly familiar with YAML syntax and can't seem to find a solution through search. I'm trying to loop through this data file: - category1: title: Title 1 sub: name: name1 desc: desc1 sub: name: name2 desc: desc2 sub: name: name3 desc: desc3 - category2: title: Title 2 sub: name: name1 desc:...
Brad
1

votes
1

answer
47

Views

how to display all checked check boxes instead of just the last one selected

namesex page final page I want it display all my checked check boxes instead of the last one selected excuse the final.erb the fistname, lastname works and so does sirname I just wanted to see if I could get all my checkboxes to work app.rb require 'sinatra' get '/' do erb :namesex end post '/name...
zachary edgell
1

votes
0

answer
52

Views

Converting PHP to ERB in Ruby on Rails

I'm new to Ruby on Rails and I have some code in PHP that will transform my xml document with my xsl document on my browser. I need some up help converting the code to erb. Any help is much appreciated, thanks in advance.
doyin odugbesan
1

votes
0

answer
28

Views

How to show only uniq tags in view?

I have the code below. I would like to make that only one tag print to view for every question. But now it prints two and more times. I know why. But I don't know how to fix it. I used uniq for first line. But I gues it is not very beautiful.
Olga Coşkun
1

votes
0

answer
20

Views

Pass Rails message with hyperlinks to JavaScript

I have a line in en.yml file which has hyperlinks in them. I need to pass the same to JavaScript and render the hyperlinks in the form of alerts. How can I achieve that? en.yml hyper_link_link_html: 'please click here here' hello.html.erb hello.js alert(hello_link);
user2452057
1

votes
0

answer
22

Views

Use ERB block as a literal in Rouge syntax highlighting

I'm trying to setup Rouge for my Rails app and I'm having issues with passing in inline ERB strings or blocks. When it reads ERB from a file it works fine however. Here is an example of what I have - Works rouge_helper.rb def rouge(file, language) formatter = Rouge::Formatters::HTML.new(css_class:...
Ryan Grush
1

votes
1

answer
28

Views

Ruby on Rails - Conditional table coloring in erb template file

I would like the cell coloring to be based on value of key as in the code above. But all values of key (7 and above) are printed just fine - but color coding seems to be just #EAEAEA for all of them. How can I enforce conditional coloring?
Biju
1

votes
0

answer
83

Views

Ugly indention with Sinatra ERB partials

I have a problem in Sinatra with ERB templating engine. Partials are rendered with wrong indention. There is no custom helpers, or sinatra-partial gem, just vanilla Sinatra. Also have 'sinatra-contrib' installed, if it makes any difference. Editor is Sublime Text, and all files use spaces for indent...
icherevkov
1

votes
1

answer
23

Views

Simple form and bootstrap incompatible css

I am trying to copy this simple design into edit mode. Here is the code displaying the image above : débat débats disciple disciples 'edit-button') do %> I copied the main design of the page to the edit mode. Unfortunately, here is what I get : I am using the simple form gem with rails and I...
Pierre Laburthe
1

votes
1

answer
45

Views

Rails: rendering link with remote: true doesn't fire AJAX

I have a project in Rails 3, with a partial _form_fields.html.erb that is rendered to a page and contains a remote link: This gets processed by a controller, and appends this same partial below itself. The controller: def new respond_to do |format| format.js end end And the related js.erb file: $('....
SRack
1

votes
0

answer
24

Views

Sinatra Flexible File Inclusion/Update Without Restart

I'm needing a way to insert a warning line (Bootstrap alert) to say the site will go under maintenance in 10 minutes. I'm using Sinatra 2.0.5 and I want to minimize the work involved for on-the-fly warnings like this that I can modify manually. I can't leave the application set with a tmp/always_r...
Rich_F
1

votes
1

answer
89

Views

Rails 5.2 credentials.yml.enc ERB not parsing

I'm trying to setup SMS texting with Twilio. I'm going thru their guide here: https://www.twilio.com/blog/2017/12/send-sms-ruby-rails-5-coffee.html but am running into an issue with the ERB in credentials.yml.enc not being parsed for the twilio credentials. I've tried adding the credentials without...
Charles
1

votes
4

answer
1k

Views

Using rails named routes within custom rendered ERB templates

I have a method on an active record class that renders an ERB template for a messaging system. The simplified code looks like this: ERB.new(template).result(binding) where binding is the current Binding of the ActiveRecord model object and template is an erb template file read in from the file sy...
johnml
1

votes
1

answer
417

Views

Who Creates Custom ActionMailer Layouts in Rails, You or the Client?

When projects get large, I imagine you might start having 100s of mailer templates: user_signup_confirmation.html.erb user_signup_failure.html.erb user_account_activation.html.erb user_account_cancelation.html.erb ... What is your workflow for handling this? Do you have them email you what they wan...
Lance Pollard
1

votes
2

answer
1.2k

Views

Custom ERB tag replacement

How can I get ERB to replace tags in a format other than for example: {{ }} Thanks
Andrew Bullock
1

votes
1

answer
237

Views

Is using js.erb files in conjunction with rails and jquery safe?

I have seen many resources on using jQuery with rails where people recommend having callback functions in .js.erb files, however I have also heard that passing data this way leaves me vulnerable to man in the middle attacks. Is this true? What are the security concerns and is there a way to do it...
Yak
1

votes
3

answer
383

Views

erb <% expression -%> in aspx pages

Do asp.net aspx views have tags that that work similar to the Ruby erb ? I don't like all these line breaks in my asp.net mvc generated html. As for the other view engines (nhaml, spark, razor) I don't want to use them yet. Quick example of the difference between and in erb: 1. Ho! Merry Christm...
Valentin
1

votes
1

answer
476

Views

How to extend Ruby ERB for handling %= tags as well?

I am using ERB for metaprogramming of some math language. If I could extend ERB functionality to handle %= tags, it would allow me to simplify my sources significantly. I simply want to get output of the line in analogy with . I have tried to dig into /usr/lib/ruby/1.9.1/erb.rb file, but got lost ve...
Andrei
1

votes
1

answer
96

Views

How to port `error_messages_for` from Ruby erb to Java JSP/JSTL?

How would you port this front-end logic from erb to jsp/jstl? Is there any Java library that does something similar?
peasoup
1

votes
3

answer
1.4k

Views

reflection of erb variables

I'm using a puppet template, which does an erb interpretation of the template file. I'd like to know all the variables available to me, however, there are variables available (e.g., fqdn) that are not listed by any of the reflection methods I'm aware of, specifically, none of these: # module consta...
Stephen P. Schaefer
1

votes
1

answer
802

Views

question on ruby erb templates

I have this script for generating config files. I am using ruby and its builtin ERB. some of my templates consists of specific formats, spaces, braces etc an example would be command { var some_var; } My problem is my ERB templates are very dirty to look at because when I arrange the code in the te...
poymode
1

votes
3

answer
446

Views

Most appropriate way to generate directory of files from directory of template files with Rails and ERB?

My goal is to generate a directory of static html, javascript, and image files within my Rails (3) app, driven by ERB templates. For example, as a developer I might want to generate/update these files: #{Rails.root}/public/products/baseball.html #{Rails.root}/public/products/football.js ..from the f...
Jon A
1

votes
1

answer
256

Views

Are ERB and require_relative compatible?

Are ERB and require_relative compatible? I got this message :31:in `require_relative': require_relative is called in erb (LoadError) What does it mean?
JCLL
1

votes
1

answer
1.4k

Views

How to get options_for_select to honor   tag

I'm trying to indent options in a select list of categories based upon their hierarchical level, e.g. Category,  Subcategory,   Subsubcategory. I've tried: , but this renders as &nsbp;Subcategory and   Subsubcategory. I've tried: , but this ignores the spaces and renders as Subcategory and Subs...
trliner
1

votes
1

answer
440

Views

How to erb'up a monitrc configuration file

Below is my delayed_job monitrc file, i wanted to use it as an erb template so that i can dynamically set the RAILS_ENV variable. Does anyone know how to do it? set daemon 120 check process delayed_job with pidfile /home/rails/public_html/myapp/shared/pids/delayed_job.pid start program = '/usr/bin/...
Pratik Khadloya
1

votes
1

answer
964

Views

Cant update .html.erb file in a Ruby on Rail application

I'm totally new in RubyonRail field: i tried to update the html in a view file .html.erb, but after uploading the file via ftp, the changes dont take place even if the file has changed. It seems to be cached, is there something I miss? D.
user191687
1

votes
2

answer
218

Views

Why am I getting a No Method and Nil Object error in the following line of codes?

I am trying to implement the following code in index.html.erb on rails and the following error appears on the server: NoMethodError in Users#index You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.each Extracted sou...
Tony
1

votes
1

answer
212

Views

Binding in 1.9.2

I used to use ERB templates everywhere using the following technique: def create_from_template(file, template, vars) contents = File.read(template(template)) struct = OpenStruct.new(vars) result = ERB.new(contents).result(struct.binding) File.open(file, 'w') { |f| f.write result } end And I use it t...
kolrie
1

votes
1

answer
792

Views

erb won't render in coffeescript file

I'm having trouble figuring out why our ruby code isn't rendering in coffeescript. Ultimately we're working towards plotting a series of markers stored in a Rails model in a Google Maps view. Because we had trouble with a loop, we tried to get a test variable to render in an alert; it's not working....
jmaliakal
1

votes
1

answer
130

Views

Why is an asterisk being replaced with all directories under / after deployment?

I was hoping someone could give some insight to a problem I noticed on my last deployment. I have an erb page with some javascript in it. There were no problems until I tried to multiply numbers. For some reason, after I deploy to the server, all asterisks are replaced with what looks like the ou...
Justin
1

votes
2

answer
1.1k

Views

rails view not updating

I have started with my first rails project using Redmine. I have started to dig into the code to get a better idea and having a hard time understanding the erb files. When I go to make a simple change to the welcome.html.erb file, I make the change and check in the browser and there is no change. On...
pertrai1
1

votes
3

answer
1.4k

Views

Rails: Generate Unique Random Number for populating a CSS class String How To?

So let's say we have a rails view with this code: Users who have the Title And what we want to do is to automatically print this line: Right aside each username the loop throws at us BUT we want X to be a different unique random number each time... How can this be accomplished?
Jmlevick
1

votes
3

answer
174

Views

How can I get the content of the block to appear in the view?

I have some code like this: And I thought of writing a helper method, like this one: def cached_snippet_content(snip_id) cache(snip_id) do cms_snippet_content(snip_id) end end However, I don't get any output in my view, even though, my erb code looks like this: What am I doing wrong?
Geo
1

votes
1

answer
1.7k

Views

jQuery syntax in js.erb

I added a new element in the js.erb file and I am trying to assign a click event to the newly added element. This is what I have in js.erb: $('#').on('click', '' ); I am getting syntax error using '$' writing the function. what is the fix here? If I have to put this function in a var within this fil...
hrz
1

votes
1

answer
333

Views

Overriding the way Integers print in .erb

I want to print numbers in my rails application with commas. As per the answer here, I could wrap every single number I print with number_with_delimiter(@number, :delimiter => ',') However, I don't want to go into my views and apply this manually. I'd much rather override the way integers are pri...
bdares
1

votes
1

answer
573

Views

Convert from haml to erb

I try to convert the code from haml to erb but I'm getting stuck and don't know why. Here is the original code I want to convert: https://github.com/gmarik/simple-backend-example/blob/master/app/views/backend/resource/_index.html.haml And here is what I have right now. Can someone take a look at it...
AgainstPIT

View additional questions