In my Rails application, I have a variety of database tables that contain user data. Some of these tables have a lot of rows (as many as 500,000 rows per user in some cases) and are queried frequently. Whenever I query any table for anything, the user_id of the current user is somewhere in the query - either directly, if the table has ...
I use paperclip to attach an avatar to users, which works fine but when a new user attempts to register it complains about the avatar bieng too small and not of the right type.
This is how i validate my avatars:
validates_attachment_size :avatar, :less_than => 1.megabytes
validates_attachment_content_type :avatar, :content_type => ['im...
My application controller looks like this
class ApplicationController < ActionController::Base
include AuthenticatedSystem
helper :all # include all helpers, all the time
protect_from_forgery # :secret => 'sup3rs3cr3t'
filter_parameter_logging :password
# Here's the interesting bit
before_filter :login_required, :except => ...
Hi,
I have following settings in my FeedbackMailer.
def notification(feedback)
from "[email protected]"
subject "Some feedback"
recipients "[email protected]"
reply_to feedback.creator.email
body({ :feedback => feedback })
content_type "text/html"
end
I am using [email protected] account to send emails for this appl...
Hi.
I have an object in Ruby called Post.
I would like to convert post into an json but also I want to include the name of the user who posted the post. The thing is user_name is not present in Post object but the user id is.
So what I effectively want is something like this
{name:"My Post", body:"My post data", user_name:"jhonny"}
...
Hello all!
I'm a newbie in rails, and I've been looking all over for an answer for this issue. Here's what I have:
class Item < ActiveRecord::Base
belongs_to :book
class Book < ActiveRecord::Base
has_many :items
Now I want to list all the items with their properties and the book associated with them. They would go under index in ...
One of my model objects has a 'text' column that contains the full HTML of a web page.
I'd like to write a controller action that simply returns this HTML directly from the controller rather than passing it through the .erb templates like the rest of the actions on the controller.
My first thought was to pull this action into a new c...
I have the following code in an Active Record file.
class Profile < ActiveRecord::Base
attr_accessor :tmp_postal_code
def postal_code=(postal_code)
@temp_postal_code = postal_code[:first] + "-" + postal_code[:second]
end
def postal_code
@temp_postal_code
end
end
I first overwrote postal_code=(postal_code) because p...
I have an edit screen for a model that's nested inside 2 other resources. To make the example easy to understand, it looks sort of like this:
Make -> Model -> Car
I have a Car edit screen that lets you edit the few fields that it contains.
(assume the url is: /makes/124/models/12512/cars/1125/edit)
I want to add a cascading pair of...
Hi, I've a portal project built in Rails 1.2.3. I've finished it at end of 2006.
The project are using the following plug-ins:
acts_as_attachment
acts_as_ferret
betternestedset
simple_http_auth
I know all plug-ins (or dependencies) was changed today, or doesn't exists anymore. The DHH says: Don't overestimate the power of versions. But...
I added Subdomain-fu in my project. In ApplicationController I have before_filter which checks url and redirects app.com to www.app.com, www.subdomain.app.com to subdomain.app.com and checks account existence (redirects to home if not exists):
before_filter :check_uri
def check_uri
if !subdomain?
redirect_to http...
Hi,
I am developing a test application and running the whole thing on my work pc. I am using my corporate mail server to send mails. It works fine normally. I was wondering how to handle any conditions like if the mail server is not reachable from my pc.
As far as i have read about it, the rails application just sends the mail and that'...
I am a front end developer (HTML,CSS,JS & jQuery) I know a bit of PHP. I am trying to grasp what Ruby/Ruby on Rails is.
On http://rubyonrails.org/ it says "Ruby on Rails is an open-source web framework that's optimized for programmer happiness"
In actual, non-dreamy terms, what is special about Ruby/Ruby on Rails, and how can a person...
I created a simple application in Rails for storing the names of cars:
script/generate scaffold car name:string
I'm looking to create an application which will connect to this using REST and AJAX to create new car names. However, I want this application to be separate from the application which I created in Rails to actually hold the ...
Hey and happy holidays
I'm working in ruby on rails and need the following:
remove all "br" html tags between "code" html tags in a string of html. The "code" tags might occur more than once.
Now, it's not screen scrapping I'm trying to do. I have a blog and would like to allow people to use the code html tags only in the comments. S...
I have SQLite3 database, which is populated with some large set of data.
I use migration for that.
3 tables will have following count of records:
Table_1 will have about 10 records
each record of Table_1 will be associated with ~100 records in Table_2
each record of Table_2 will be associated with ~2000 records in Table_3
The...
I am attempting to create a web-based game in Ruby on Rails. I have a model named 'Game', which has a datetime in the database entry that corresponds to a time that I would like the server to call the Game model's update_game function. Depending on the game's settings, this could be every 30 seconds to every 12 hours.
Ruby on Rails ...
I have the following database table:
account
-
id
first_name
last_name
email_address
password_md5_hash
last_logged_in
last_ip_address
date_time_created
As you can see, an account record has several fields with values the user will not enter themselves. For instance, the password_md5_hash will be the hashed value of the password they e...
how to enable utf-8 support in rails??
...
Say, I have this in one of the controllers:
def show
case current_user.role
when 'manager'
render :text => 'Manager view!'
when 'admin'
render :text => 'Admin view!'
end
end
The thing is, that instead of 'render', of course, there's a bunch of code and it all stops look pretty very fast. Also, I h...