I am trying to set an attribute on an object that I am creating. I feel like this should work:
def create
@album = Album.new(params[:album])
@album.user = current_user
if @album.save
flash[:notice] = 'Album was successfully created for ' + current_user.login + '.'
redirect_to albums_url
else
rend...
I am trying to use image_magick gem to process image uploads, but rails can't locate it.
I have installed the gem successfully using:
gem install mini_magick-1.2.3.gem --local
gem update system
gem cleanup
and my model has
require 'rubygems'
require 'mini_magick'
However, I still get the error:
no such file to load -- mini_magic...
Does anyone know the best lightweight Rails benchmarking tool?
I need to get performance statistics of the webserver and simulate authentication + page navigation per session. I've been trying to use httperf, but been encountering TamperingWithCookie exception in the application.
Ideally, I'd like to separate the application and databa...
I have a PostgreSQL DB on a remote VPS server (CentOS 5) and I'd like to connect to have a Rails application connect to it from my local Mac laptop. On my laptop, I have the ActiveRecord PostgreSQL adapter installed -- postgres (0.7.9.2008.01.28).
I read in the PostgreSQL docs:
The password-based authentication methods are md5, cryp...
Is there an easy way to run a single migration? I don't want to migrate to a certain version I just want to run a specific one.
...
If I want to provide an alias for a controller, I can use map.resources :rants, :controller => 'blog_posts' yoursite.com/rants points to the blog_posts controller fine.
How do I give an alias to a nested resource, for example yoursite.com/users/5/rants ?
...
Hello,
I want to run two rails websites (homepage and app) on the same database. However, migrations dont work because both websites try to use schema_migrations table at the same time.
Is it possible to override default schema_migrations table name? Any other ideas how to solve this problem?
...
I am using Sphinx with the Thinking Sphinx plugin. I have indexed a model called Venue with the following code (and the rake thinking_sphinx:index command)
define_index do
indexes :name
indexes city
indexes zip
end
I obtain the results in my controller with this code:
@venues = Venue.search params[:search]
and I render...
In my Rails application I have a User model (more or less built by RESTful Authentication), and several other models belonging to the user.
So let's say, for example:
user has_many :posts
post belongs_to :user
Anywhere in the users resource I can access the user variables as I would expect.
@user.name, @user.email, @user.login, etc. a...
I'm using a simple model for user authorisation with two ActiveRecords User and Role
User and Role have a HABTM relation to each other.
I tried to created a user interface for assigning roles to users with simple checkboxes - just like in Railscasts Episode #17.
My problem is that neither User#new nor User#update_attributes use the par...
I am going to develop a Rails application and the designer wants to include tabs as part of the interface / navigation (probably it will included nested tabs).
Are there any places you would recommend I look, as I guess this has all been done before.
Thank you.
...
Something like
Rails.cache.delete('site_search_form')
doesn't seem to work. Is this possible? Thanks.
...
We have the following situation:
We invoke a url which runs an action in a controller. The action is fairly long running - it builds a big string of XML, generates a PDF and is supposed to redirect when done.
After 60 seconds or so, the browswer gets a 200, but with content type of "application/x-unknown-content-type" no body and no Re...
Are there any tools to test the security of your rails application?
Things that can automatically test sql injection, cross-site scripting, etc...
...
I frequently must correct the following rails code:
assert_equal value, expected
The two arguments to assert_equal are out of order, and should read:
assert_equal expected, value
In vim, what is the most efficient way of going from the first line to the second?
...
I think my question is best described as an example. Let's say I have a simple model called "Thing" and it has a few attributes that are simple data types. Something like...
Thing
- foo:string
- goo:string
- bar:int
That isn't hard. The db table will contain three columns with those three attributes and I can access them w...
I have a model which is generated by parsing a data file. There are several interesting values which are not present in the original data file but can be derived from the ones that are.
However, many of these derived values are expensive to compute, so I would like to store them in the database once they have been computed.
I have trie...
I'm trying to create unique anchors for every comment on my blog so a person can take the url of an anchor and paste it in their browser, which will automatically load the page and scroll down to the point in the page where their comment starts.
Perhaps I'm going about this the wrong way but I've tried this which was to no avail.
Comm...
I have a list of keywords that I need to search against, using ThinkingSphinx
Some of them being more important than others, i need to find a way to weight those words.
So far, the only solution i came up with is to repeat x number of times the same word in my query to increase its relevance.
Eg:
3 keywords, each of them having a level ...
In every webapp I build, I come across this issue. I want to set classes on HTML elements conditionally. For example, sometimes the <div> for a post looks like:
<div class="post">...</div>
And sometimes it looks like this:
<div class="post even recent replied_to author_is_admin">...</div>
Each class after post is there because some...