i have my constants initialized in environment.rb like this :
Rails::Initializer.run do |config|
...
MAX_BID = 10
end
i would like to use this constant in my models and views,what is the correct syntax?
if a use it a model its says
NameError: uninitialized constant User::MAX_BID
i understand that it is looking for the const...
Hello,
how would I develop an Email client in Ruby-on-rails taking Gmail as an example? I would be especially interested in the send email functions
Thanks for any pointers
...
I am seeing several strange requests like this, with urls like /sitemap/, /google_sitemap.xml.gz, /sitemap.xml.gz, /google_sitemap.xml, /cgi-bin/awstat/awstats.pl, etc. The default rails behavior dumps these long stack traces into my log, like the following:
ActionController::RoutingError (No route matches "/rails/info/properties" with ...
We are just giving MongoDB a test run and have set up a Rails 3 app with Mongoid. What are the best practices for inserting large datasets into MongoDB? To flesh out a scenario: Say, I have a book model and want to import several million records from a CSV file.
I suppose this needs to be done in the console, so this may possibly not be...
Hello Railers,
I have a simple yield use case and for some unknown reason the default case is never shown:
In my super_admin layout I have:
<%= yield :body_id || 'super_admin_main' %>
My controller
class Superadmin::GolfsController < ApplicationController
layout "super_admin"
def show
end
end
My show view
With or withou...
Hi, for some reasons I am trying to translate the following RoR view code to a GSP view:
List<Object> objectscontains the data I want to display in 3 columns
<%
modulo_objects = @objects.length % 3
base = @objects.length / 3
base = base.ceil
case modulo_objects
when 0
cols = [base, base, base]
when 1
cols = [base, base + 1, base...
I'm a Ruby on Rails newbie. I'm learning Rails in my spare time (my day job is C++ developer) and I like it. I would like to be paid to do Rails development full-time instead of C++.
How can I find a job in Rails when most job offering requires 2-5 years of Rails experience? What is the most effective strategy to get some credibility a...
Using Authlogic and Authlogic Facebook Connect.
before_filter works great. Get name and facbook_uid saved in db. Only problem is that it saves a new record every time.
Need help figuring out how to build some type of find_by_facebook_uid_or_create_user
I have tried reading up on the API's for facebooker, but this is way over me. :(...
Hi Everyone,
I am working on a Rails application that has user authentication which provides an administrators account. Within the administrators account I have made a page for sitewide settings.
I was wondering what the norm is for creating these settings. Say for example I would like one of the settings to be to change the name of t...
So I just got started in Rails, and I'm trying to create an Object (a book_loan in my case) with a Form. The thing is that I get to this form by clicking on a book, so I pass the book_id as a parameter, like localhost:3000/loans/new?id=1.
Now I don't want the user to be able to set the book id field in the form, since I already know th...
I'm generating a PNG file in Flex from graphics drawn by user. I would like to send the file to Ruby on Rails backend and I'm using RubyAMF in other parts of the application.
I found ways to upload the file using FileReference which uses HTTP but I prefer to send using RubyAMF ,if possible, as it's more efficient.
If this is possible w...
I am attempting to follow this tutorial: http://vimeo.com/6459254
I am using IronRuby and get to the point that I create a user in the system. Now all pages fail with the following error when trying to render the page:
Class System::Int64 does not have a
valid constructor
Any other IronRuby folks hit this issue and figured out a...
How can I possibly turn into named_scope?
def self.hero_badge_awardees
return User.find_by_sql("select users.*, awards.*, badges.badge_type
from users, awards, badges
where awards.user_id = users.id and badges.id = awards.badge_id and badges.badge_type = 'HeroBadge'")
end
...
I have a query used for statistical purposes. It breaks down the number of users that have logged-in a given number of times. User has_many installations and installation has a login_count.
select total_login as 'logins', count(*) as `users`
from (select u.user_id, sum(login_count) as total_login
from user u
...
I can't figure out where exactly to go in order to write the Ruby code itself. I know that I can enter things line-by-line in Terminal (I'm on a Mac), but I'd like to figure out how to start using something like Xdrive (Apple won't allow me to download Xrive because I have OS X 10.5, not 10.6).
What steps do I need to take in order to ...
Few questions:
Is it possible to call a controller method in a helper module (e.g., application helper)?
If so, how does the helper handle the rendering of views? Ignore it?
In what instances would you want to call a controller method from a helper? Is it bad practice?
Do you have any sample code where you're calling controller method...
Hi all,
I'm trying to use url_for(:back) to create a redirect leading back to a previous page upon a user's logging in.
I've had it working successfully for when the user just goes to the login page on his or her own. However, when the user is redirected to the login page due to accessing a page requiring that the user be authenticated...
Does anyone know the way, or a place where I can find out how to do this?
Basically, all I want to do is connect a foreign key between two tables.
Is it true, that all I have to do is write the "belongs_to" and "has many" ?
...
I have a Ruby hash that reaches approximately 10 megabytes if written to a file using Marshal.dump. After gzip compression it is approximately 500 kilobytes.
Iterating through and altering this hash is very fast in ruby (fractions of a millisecond). Even copying it is extremely fast.
The problem is that I need to share the data in this...
Hi everyone,
I have a system where I need to login three user types: customers, companies, and vendors from one login form on the home page.
I have created one User table that works according to AuthLogic's example app at http://github.com/binarylogic/authlogic_example. I have added a field called "User Type" that currently contains ei...