Displaying 20 results from an estimated 9000 matches similar to: "<% if ... -%> What is this?"
2006 Aug 28
10
Templates and arrays
I''m in the process of documenting templates right now, and I figured
I should see what happens when you use them with arrays:
$ cat ~/bin/test.pp
$values = [this, is, an, array, of, values]
$content = template("/tmp/templates/testing.erb")
file { "/tmp/temtest": content => $content }
$ cat /tmp/templates/testing.erb
<% values.each do |val| %>
I got
2006 Feb 20
7
Native erb lacks -%>, where is Rails'' erb?
Native ERB in ruby, and eruby, seem to lack the -%> feature for
suppressing trailing newlines. Thus
erb -n script
gives errors. Where is Rails ERB so I can invoke it directly?
Thank you
Hugh
2006 Jul 13
3
Performance diff between rendering partial vs. calling a helper?
Hi,
Is there any performance difference between rendering partials vs. calling a
helper? When we initally started coding we built a bunch of small partials
and if there is a significant performance overhead with them, we''ll probably
try to switch them over to helpers. They seem like they would be quite
similar but I don''t know the full details of how partials are handled.
2006 Feb 07
17
Easy way of dealing with nil properties in templates?
Is there an easy way to deal with nil properties in
templates? All I''m aware of are these methods, and
it''s quite tedious and surely violates DRY.
<%= @member.name unless @member.name.nil? %>
<%= @member.name.to_is %>
<%= "#{@member.name}" %>
csn
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the
2006 Jan 21
19
RoR - Mac OS 10.4.4 on Intel
I got a new 20 inch iMac dual core today and am busy getting it all
setup. A couple of issues though:
1. Is the Ruby 1.8.2 install by Apple still botched or has that been
fixed? I recall someone had fixed the rbconfig.rb to get it working.
Is this something I still have to do?
2. Does anyone know if Locomotive is using the uniersal binaries, or is
it targetting PPC yet? I couldn''t
2006 Feb 19
8
require ''digest/md5'' not working on Mac or Windows
I''ve tried the following line in ruby script/console
require ''digest/md5''
Both my Mac (Intel iMac) and my Windows box return "false"... Any ideas
what could be wrong? I was trying to do the RoR Recipe on page 54 of
Chad Fowler''s new (beta) book.
-Mark
--
Posted via http://www.ruby-forum.com/.
2013 Jul 23
1
Postgres adapter misconfigured on Linux?
I''ve written a simple Rails migration that adds an index to an existing
Postgres table:
class AddIndexToEvents < ActiveRecord::Migration
> def change
> add_index :sf_events, :account_id
> end
> end
However, when I run the migration, it fails due to a syntax error on the
CREATE INDEX line. I''m expecting some SQL like this to be generated:
CREATE INDEX
2006 Jul 23
4
Newbie question about .rhtml
Hi everyone, coming from PHP something in the .rhtml files has been
confusing the heck out of me.
Why does this work?
<% for header in @all_headers %>
<%= header.subject %>
<% end %>
and both of these don''t work
<% for header in @all_headers
puts header.subject
end %>
---------------------------------------
<%= for header in @all_headers
puts
2006 Jan 08
3
Getting the current Action in the Model
Is it possible to get the current Controller''s action from within the
Model? I have a situation where I want a piece of validation to run on
edits, but not on new creates.
Thanks,
- Mark
--
Posted via http://www.ruby-forum.com/.
2006 Jan 14
4
hide_action doesnot hide view
The view file (eg. apps/views/items/list.rhrml) is still displayed even
when the action is hidden (hide_action :list). How can I hide view file
form being automatically displayed in this circumstance?
thanks,
jigar
--
Posted via http://www.ruby-forum.com/.
2012 Mar 08
2
How do I quote a percent sign in the text of a template?
Hi
I am scratching my head on this not being a ruby person...
I am turning my kickstart files into templates, but am having issues with
percent signs in free form text. This returns a syntax error:
%post
OK, fine , let me escape it:
%%post
No error, but the end result is
%%post
Not quite what I wanted
I''m missing something blindingly obvious - can someone point me to it? :-)
2007 Nov 16
4
Returning vectors of two different data types back to R environment (from C).
Hello,
Quick question.
I have written a C function - I would like to make it return two vectors to
the R environment - one STRSXP vector, and one INTSXP vector. Is this
possible/ easy to do using the API?
I looked, but could not find the answer to this question in the "Writing R
Extensions" guide.
Thanks very much for your help!
Charles
[[alternative HTML version deleted]]
2008 Dec 14
2
custom REST action - template question
Hallo phorum,
i have custom rest action.
routes.rb:
map.resources :schools, :collection => { :graduations => :get }
SchoolsController:
def graduations
@schools = School.graduation(true)
end
link somewhere in navigation:
<%= link_to ''Schools with graduation'', graduations_schools_path %>
All works OK for me, but Rails needs (of course) a template for
controller
2006 Mar 15
3
Special characters in ERB
I''m pulling text out of a database that contains special characters,
like the trademark sign. For example, a typical string might be like this:
string_from_database => "Some Special Brand\231 is for sale this
Thursday through Friday."
The \231 is the trademark sign (TM). ERB converts this to question
marks. So, my question is -- how can I get it to display the trademark
2005 Dec 16
5
Question: image_tag(source, options = {})
image_tag(source, options = {})
Ok, when I want to use an image I added the following code:
<%= image_tag "dsf.jpg" options = {[align="right", style="padding-right:
10px; padding-top: 5px;"]} %>
However, this doesn''t seem to work, it doesn''t like how I have the
"options" part setup. I''m sure there is something very easy
2005 Dec 17
2
Encrypting files
Anyone know of a good (fast) way to encrypt/decrypt uploaded files in
RoR? I''ve seen this project: http://ezcrypto.rubyforge.org/ but it
only seems to encrypt strings and such. I need to encrypt files once
they are uploaded, then decrypt them when they request the file back.
Any ideas?
Thanks,
Mark
--
Posted via http://www.ruby-forum.com/.
2007 Sep 01
2
Getting JSON from the body of a POST
I have a Flash application that is sending JSON data to a Rails app. I
want to be able to read the JSON from the controller. Does anyone know
where I can go to figure this out? I''ve Google''d around but can only
find instances of converting to JSON, not the other way.
Example:
Flash -> Sends JSON -> Rails Controller receives JSON and converts it to
a class
--
Posted
2004 Oct 21
3
error in plot.dendrogram (PR#7300)
Hi,
hres <- hclust(smatr,method="single")
hresd<-as.dendrogram(hres)
as.dendrogram(hres)
`dendrogram' with 2 branches and 380 members total, at height 2514.513
plot(hresd,leaflab="none") #<-error here.
#the plotted dendrogram is incomplete. The x axis is not drawn.
#The interested reader can download the
save(hresd,file="hres.rda")
#from the
2006 Jun 24
3
Performance vs normalization best practice
I have a common situation and would like best practice suggestions from some
of you more experienced rails developers.
In my DB I''ve normalized tables in a traditional manner, e.g. I have Posts
which have authors stored in a Users table.
My problem is when I go to show a list of Posts and I want to display the
author name (e.g. post.author.name)
ActiveRecord appears to do a SELECT
2009 Dec 10
2
How to customize the default scaffold?
I know the scaffold generator is really only useful for beginners
and/or very the preliminary state of a project, but I find that I use
it a lot (especially, since I am still a beginner). There are a
couple of things I find myself tweaking (or wanting to tweak, but
never getting around to tweaking) each time I generate a new scaffold:
1) Change the layout from blah.html.erb to