similar to: Mixing html tags and Ruby blocks

Displaying 20 results from an estimated 20000 matches similar to: "Mixing html tags and Ruby blocks"

2010 May 13
6
to "loop through" the instance variables of ActiveRecord?
to wrap each instance variable of an ActiveRecord object between "<td>" and "</td>", is there a way to "loop through" them, at least in the debug mode, no matter there is getter methods to get them or not, or at least the ones with the getter methods? Such as <% @stories.each do |s| %> <%= "<tr>" %> <% s.each_property
2006 Jul 11
1
Nil.
before_filter :login_required @session[''user''] ||= {''login'' => ''guest''} if @session[''user''].login.downcase != "mohammad" || "nick" redirect_to :controller => ''login'' end what''s wrong with this I need this is an admin area is there an eaiser way to do this? Or an error
2006 Jan 27
17
Multiple Model Validation
Hey All ! I have a form which contains two models. I would like both models to be validated, but have their validations aggregated on the page. If I do: <%= error_messages_for(:model1) %> <%= error_messages_for(:model2) %> It puts two big validation blocks on the page. I would like all the errors from both models, but only in one validation box. Is this possible ? All my attempts
2006 Mar 11
11
Noob needs help with ''if'' block
Hello all. I''m a noob at Ruby on Rails, only started learning a few days ago, but I''m loving it so far. I do have a few years experience with PHP, ASP, MySQL, etc., so I''m not *totally* clueless, though. :) Anyway, I''m having trouble with something that should be fairly trivial: I have an ''if'' statement that is supposed to print out a table
2006 Jan 02
9
Generating nice tables
Making tables in templates is pretty easy, except for one minor problem. They tend to be fairly ugly. If you have a model with three attributes, it''s very easy to create an html table that looks like this.. Col1 Col2 Col3 A B D A B E A C F A C G Which becomes difficult to read when you have a lot of repeated data. What I would really like to generate
2005 Mar 09
21
Converting time retrieved from MySQL
I''m having a problem converting a date retrieved from my MySQL database and I''m hoping someone can help. MySQL stores the date/time as this: 2005-03-08 17:00:34.0 and according to my Pickaxe book Ruby stores times as "the number of seconds and microseconds since [...] January 1, 1970". All well and good. Unfortunately, RoR is converting my date to this:
2012 Jun 26
4
ActionView::Template::Error (undefined method `strftime' for nil:NilClass)
Hello, I''m a newbie. I need help resolving this issue. I recently added a pdf to the newsletter admin section of the website and now I can no longer view page 2 of the list of pdf''s. Nor can I login to see the newsletters as a student. I''m using Ruby 1.9.3, Rails 3.2.1. Here''s the information from the log file. ActionView::Template::Error (undefined
2011 Sep 06
8
Ajax and rails 3 UJS (jquery)
Hi, guys, I''m in the midst of moving an app from rails 2.3.8 to rails 3.0.9. Sadly, rails 3 no longer has javascript generators and I''m now forced to do more javascript. For my project, I have selected jQuery as the javascript framework for my rails 3.0.9 app. What I have done to have my app''s deletion link (for each item) trigger an alert box when the deletion
2010 Sep 18
11
Commenting in an ERB without generating a compiling error
Hello, I have the following: <% @projects.each do |project| %> <tr> . <td><%= link_to ''Destroy'', project, :confirm => ''Are you sure?'', :method => :delete %></td> . </tr> <% end %> How can I safely comment out the TD line above? Do I have to use the =begin way? -- You received this message because you
2011 Jun 15
1
uninitialized class variable @@env in OCI8
Can anyone help me with the uninitialized class variable @@env in OCI8 error raised in my app\views\xxxx index.html.erb file Thanks in advance Below is the code and the result of bundle show. I am using Windows 7 <h1>Listing comics</h1> <table> <tr> <th>Title</th> <th>Issue</th> <th>Publisher</th>
2006 Jan 27
10
html special characters. h() failure.
I was trying to convert a some text with the (r) character it so it replaced character \xAE with &reg; h(@item.description) didn''t do anything. I need to use @item.description.grep(/\xAE/,''&reg;'') for it to work. I think the h() function should be able to do all the codes that are available. Regards Neil.
2006 Aug 11
2
Array#chunk method, maybe someone will find this useful
class Array # break an array up into <size> chunks def chunk(size=1) return self if self.empty? raise ArgumentError if !size.kind_of? Integer y = self.length.divmod(size) rows = (y[1] > 0) ? y[0] + 1 : y[0] arr = Array.new(rows) (0...rows).each do |i| arr[i] = self.slice(size*i, size) end (arr.last.length...size).each { |i| arr.last[i] = nil }
2008 Apr 24
3
Dynamically Naming a Variable
Hello, I would like to dynamically name a variable... for example, in my program, I iterate over a SQL query that gives me ''displayname'', ''phone_office'', and ''phone_mobile'' (in the actual query there are many more columns). For each row in the results, I want to create an array with [0]=''phone_office'' and
2007 Oct 15
6
SQL injection with :order, :limit, :group
I know how to avoid SQL injection attacks when you use :conditions User.find :first, :conditions => ["login=?", params[:username]] but how about with :order, :limit or :group? # uh-oh...spaghetti-oh User.find :first, :order => "login; delete from users; select * from users" Pat --~--~---------~--~----~------------~-------~--~----~ You received this message because you
2009 Oct 23
4
error: nested-routes with nested-model having foreign keys
Hi, I have this Test, User and Project models where every test belongs_to a project and project has_many tests. Test also belongs_to User as ''owner''. Then i followed railcast#139 to create nested route as - map.resources :projects, :has_many => :tests But somehow i get this error when url is ''http://127.0.0.1:3000/ projects/1/tests'' in
2013 Apr 03
3
arrayInd and which
Folks, I have Googled but not found much regarding arrayInd aside from the "which" help page. Any good examples or docs on what arrayInd does that is better or different from which()? In addition take the following 20x10 matrix: td<-structure(c(1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 1, 6, 6, 6, 6, 6, 6, 6, 1, 6, 6, 6, 6,
2009 Nov 26
9
ActionView::TemplateError (can't convert ActiveRecord::Error into String)
I cannot work out why this error is appearing. ActionView::TemplateError (can''t convert ActiveRecord::Error into String) on line #3 of app/views/button/_show_enquiry.html.erb: 1: <h1>Send us a message</h1> 2: <% remote_form_for :enquiry, :url => {:action => ''send_mail''} do | f| %> 3: <%= error_messages_for ''enquiry'',
2006 Jul 21
1
Passing a variable between methods
Hi, I am trying to add search functionality to may application. I am struggeling to pass my query to the controller and then show all my search results in another view. How would I do this? Model: class Advert < ActiveRecord::Base belongs_to :user def self.search(query) if !query.to_s.strip.empty? tokens = query.split.collect {|c| "%#{c.downcase}%"}
2012 Jun 25
1
ActionView::Template::Error (undefined method `strftime' for nil:NilClass):
Hello, I''m a newbie. I need help resolving this issue. I recently added a pdf to the newsletter admin section of the website and now I can no longer view page 2 of the list of pdf''s. Nor can I login to see the newsletters as a student. I''m using Ruby 1.9.3, Rails 3.2.1. Here''s the information from the log file. ActionView::Template::Error (undefined
2008 Jul 12
6
Create db row in my partial template
Hi, When I use script/generate scaffold for my db it automatically creates that page where I can select to add a new item to the database. In the controller, the create method looks like this: def create @user = User.new(params[:user]) respond_to do |format| if @user.save flash[:notice] = ''User was successfully created.'' format.html {