similar to: Splitting controller

Displaying 20 results from an estimated 500 matches similar to: "Splitting controller"

2008 Nov 13
3
Creating a file and saving in public directory
Hello, I''m fairly new to Ruby on Rails. I have a model called Report and I''m trying to create a text file that is saved in a /public/report directory. I''ve had a look at the ruby api but I can''t seem to get this working. The current code I have is: #report.rb class Report < ActiveRecord::Base after_save :write_file def write_file if @file_data
2009 Apr 16
0
how to convert the find_by_sql code to the find code
I want to convert following query into pure ruby one i.e. by using find @us_state_sales=SalesReport.find_by_sql("SELECT z.state, sum(s.royalty_price) as royalty_price, sum(s.units) as units FROM sales_reports s, zip_codes z WHERE royalty_currency = ''USD'' && z.zip_code=s.postal_code GROUP BY z.state ORDER BY royalty_price desc LIMIT 10") i try something like
2005 Nov 24
1
Log question
development.log contains quite a few SELECTS on system tables like COLUMNS. Wouldn''t it be more efficient to cache this info? I''m also wondering about strings like "[4;35;1m". What''s their purpose and is it possible to get rid of them? They look like screen coordinates and makes no sense in a text file. Christer Processing ReportController#create (for
2006 Jun 07
1
Setter that converts a float attribute to integer
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2008 Apr 11
0
textmate-like autocomplete
I''m using autocomplete fields in my app and it would be nice to have functionality like in textmate where it finds the closest match even if you don''t type it exactly right. For example, to find report_controller.rb in textmate press cmd-T and type repocon. In my app if you type repocon it doesn''t find report_controller.rb because it doesn''t match exactly. I
2006 Jun 07
2
Problem with a setter that converts euros to cents
Hi, I have some problems with an application where I''m using custom accessors to do currency conversions. In my model, I have a price attribute in the database that stores the value in cents, to avoid future problems with float arithmetic and round. But at the views, I would like to show the price in euros, with decimal for the cents. So I defined a new attribute called price_in_euros,
2006 May 19
2
where can I find a list of all available rake functions for Rails
Hi all, Do you know where can I find a list of all available rake functions for Rails. Many thanks. Yi -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060519/45a2ae96/attachment.html
2007 Mar 07
10
MiddleMan.worker blocks?
Hello - I am observing that calls to MiddleMan.worker return only after the worker has completed its work. This puzzles me, and I presume that I am doing something wrong. Can anyone make suggestions? Snippets from my code are: class ReportController < SecurityController ... def create_xml_report(report,start_time) constraints = get_constraints(report,start_time,false)
2011 Feb 03
0
Correct way to exclude attributes from json serialization
Hi I''m using Mongoid and Rails 3, and I want to serialize one of my mongoid documents to json for publishing via a controller, e.g. class ReportController < ApplicationController respond_to :json def show report = Report.where(:report_id => params[:id]).first respond_with report end end This works ok, but pushes out every attribute on the document
2006 May 18
4
Problems using ''select''
I use :filter action to display form and allow record filtering. It contains form with combo box, submit button and list of record matching value in combo. filter.rb: class Filter attr_accessor :owner def initialize(params) @owner = ''''; if !params[:filter].nil? and params[:filter].has_key?(:owner) @owner = params[:filter][:owner] end end end Controler: @users =
2006 Mar 27
3
Enumerable?
Hi, Can anyone please point me to some docs on Enumerable. I can''t seem to find anything on how to use it. Thanx -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060327/0825d5e8/attachment-0001.html
2006 Nov 13
5
Routes problem
I want to connect default route to controller Report::SalesController, so I have line: map.connect '''', :controller => ''report/sales'' in config/routes.rb SalesController is in app/controllers/report/sales.rb and is declared as: class Report::SalesController < ApplicationController ... end The problem is that when I try to open root url of my application I
2006 Jul 06
3
Calling Method
Is there a way to call a method if I only have a string that contains the method name. For example: @methods = [''method1'', ''method2'', ''method3''] @step = 1 # I want to call method2 which has a definition in this class -- Posted via http://www.ruby-forum.com/.
2006 Apr 06
2
making an integer from a float
Does anybody know how to turn a floating-point number (i.e. 60.345) into an integer by cutting off or rounding the decimal portion? Either method, or both, would be quite welcome. Thanks! This forum rocks! -- Posted via http://www.ruby-forum.com/.
2006 Feb 01
4
Where is the send() function?
Hi, in the tutorial "4 Days on Rails" the following code fragment is used: ,---- | <% for column in Category.content_columns %> | <td><%=h category.send(column.name) %></td> | <% end %> `---- Apparently, the send() function returns the column value by name, but where does this function comes from? Unfortunately, neither the tutorial nor the API
2006 Apr 20
7
checking date
Radrails created a field for date <%= product.date_available.strftime("%y-%m-%d") %> What does this mean? Should the definition be date or datetime? I tried both and no results Jim -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060420/ed0cbb14/attachment.html
2006 Mar 28
11
setting widget attributes
I''m trying to set attributes of widgets in subclasses like the following. class PersonTable < FXTable def initialize(owner) options = TABLE_COL_SIZEABLE super(owner, nil, 0, options) visibleRows = 5 ... end end visibleRows doesn''t get set. However, if I do this self.visibleRows = 5 then it does. Shouldn''t it work without "self."?
2006 Jul 25
3
Saving to_xml to a file
Ok, one more question... I can dump the database to xml by doing User.to_xml I''m wondering if I can save it to a .xml file. I''m having trouble finding documentation on this. Thanks!! -- Posted via http://www.ruby-forum.com/.
2006 Jun 06
4
change 1-06-2006 to 1st July 2006 (date formatting)
Hi, I have a few dates coming from the datebase in the format ''DD-MM-YYYY'' How can I change this in to a more human readable format? such as 1st July 2006 Thanks Scott -- Posted via http://www.ruby-forum.com/.
2007 Feb 16
13
negate the regexp in validates_format_of
Railsters: ActiveRecord''s validation system puts other database systems to shame. However, the newbies might not know how to write a regexp that excludes a match, instead of tests for it. Understand - I''m just asking this question to help them. I have been using Regexps since ''grep'' on Xenix! But the newbies here might not know how to do this: