I'm trying to figure out the best way to hide certain fields in user profile based on user's preference. So far I'm using a boolean field and an if, then statement.
<% if @user.show_email == 'true' -%>
<%=h @user.email %>
<% else -%>
hidden
<% end -%>
I was wondering if I could use declarative_authorization or some other better me...
Now that the Rails 3 beta is here, let's take a little straw poll.
Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you're not planning on upgrading any time soon, tell us what's stopping you.
...
I have a Mongrel cluster behind nginx and am trying to get nginx to serve up the static contents of my site with the following rule (RESTful URLs):
location / {
if (-f $request_filename) {
break;
}
if (!-f $request_filename) {
proxy_pass http://mycluster$request_uri;
br...
At the moment I store each option in its own class attribute but this leads to hard to read code when I need to access the passed options from instance methods.
For example if I pass a column name as an option I have to use self.send(self.class.path_finder_column) to get the column value from an instance method.
Notice I have prefixed ...
Well, not really reinventing, however, we have a large content-based website which handles load (after we fixed the SQL pooling issue) to a certain point, then we just run out of steam. A lot of this is due to bad code we are trying to fix up, but a lot is just due to the level of requests etc.
We were considering page caching, because ...
On my login form I want to display one simple error message like "Sorry, email or password is invalid" whenever user enters invalid email and / or password; instead of standard fancy message with heading and unordered list.
...
I have a controller:
class StatsController < ApplicationController
require 'time'
def index
@started = "Thu Feb 04 16:12:09 UTC 2010"
@finished = "Thu Feb 04 16:13:44 UTC 2010"
@duration_time = stats_duration(@started, @finished)
end
private
def stats_duration(started, finished)
time_taken = distance_o...
Hey all,
I edited this message do to sloppiness and changes.
def student_test
@student = Student.for_test.find(params[:id]) if params[:id]
@student ||= Student.new
run_sequence :testize
end
def test_finalize
Student.transaction do
if (params[:student]) and @student.update_attributes(params[:student])
@student.test!
end
room = Room...
I want to test the waters of mongodb together with RoR for a bit. I am trying to create the project with the following command:
rails mono_test_app -m http://gist.github.com/raw/284753/b5584c78fb5d29ab39a8218090801ea89b95a541/Rails%20MongoMapper%20Template
Part of the output is
create log/test.log
applying template: http://gi...
I have a Rails 2.3 web application that uses the collection_select helper with :multiple => true to handle a habtm relationship. This is working fine to set one or multiple values, however I have not figured out how to allow to REMOVE all selections.
Code:
<%= f.collection_select :category_ids, Category.find(:all), :id, :name,
{ :...
I have a rails controller which must return a .csv file and I'd like this page to use cache.
The cache works fine when I use a .xml format (it returns 304 http status), but when the format is csv, it always returns 200 http status.
here is my controller code:
def index
@machines = Machine.all
respond_to do |wants|
want...
For example, I need to convert time from UTC to local. And I use Time.zone to do this.
1.Time.zone = local_zone_name
2.Time.zone.utc_to_local(utc_time_var)
But I'd like to avoid the usage of the first line since I believe this approach modifies the class variable. Any suggestions? Thx in advance!
...
I am trying to get the hostname of the machine which a rails application is running on from the controller.
What would be the best way to do this taking into account it should work on both windows and linux?
...
Is there anyway to setup simple task scheduling inside of a rails app? There are pieces of code that I want to run every hour, or every day or every week. I don't want to break them out into separate scripts that I then have to schedule via cron jobs. If I did that, then I'd have to remember to backup the scripts, and if I rebuild a serv...
I saw this on a blog today, and I thought, finally! Rails will have something like HQL or Linq. Um, or not. I couldn't find anything about this.
What I really want to know: will I be able to forget what the tables are called and use the object names only? Can I finally forget join syntax? I'd like to do that before I start forgetting ev...
I'm using ActiveResource to consume a REST service. The xml from the service looks like:
<Person>
<FirstName>Kevin</FirstName>
<LastName>Berridge</LastName>
</Person>
ActiveResource parses this just fine, but it uses the names verbatim. So the model class will look like:
p = Person.find(1)
p.FirstName
p.LastName
I would much ...
Is it possible to use kerberos to authenticate a user under rails? Are there any existing plugins (preferably which extend authlogic's functionality) to do this?
...
Let me explain my problem:
I have 2 models:
class User < AR::Base
has_many :contacts
end
class Contact < AR::Base
belongs_to :user
belongs_to :user_contact_id, :class_name => "User", :foreign_key => "user_contact_id" # The "contact" is an ID from the table user.
def self.is_contact?(user_contact_id)
# CHECK IF THE RECORDS EXIST ...
Is there a standardized command to determine the version number of a plugin, similar to ruby script/about? For example, I need to figure out which version of exception_notification I'm running. Here's my list of plugins in my vendor/plugins directory
active_merchant annotate_models calendar_date_select gruff ...
When you get a new badge on stackoverflow.com, a bar appears at the top of the screen informing you of your achievement. It sticks around until the user closes it.
I rather like that system of informing the user about new news related to the site or their account. It's fairly unintrusive, but still clearly communicates the information...