For my school project I am buiding a time registration program. It is my first in ruby on rails, so even the simplest things are hard . ;)
The situation:
Users can work on a project, and I want to display in a chart how many hours each user worked on a project, let's say, each month. The chart plugin works like this:
first_serie = O...
How can I change the (default) type for ActiveRecord's IDs? int is not long enough, I would prefer long. I was surprised that there is no :long for the migrations - does one just use some decimal?
...
Hi, I've been working on a rails app that uses the restful authentication plugin. It requires a new user to activate their account through email verification. This has been working up until a few hours ago, when the application suddenly started to fail on email delivery. Instead I am greeted with the following error message:
undefin...
Any ideas on how to get the width and height of the thumbnail image? photo.width returns the original photos width. I am storing the width of the thumbnail in the database, I'm just not sure how to access that object.
Doesn't work:
<%= image_tag photo.authenticated_s3_url(:medium),
:width => photo.width,
:he...
Hi all!
This is my first post on Stack, so please bear with me if I breach any protocol.
I'm working on a project in Rails (2.1.2), and I have a relations scenario that looks like this:
event [has_many] days
People (in different categories) can sign up for event days, giving the following binding results:
category [has_many] custom...
In my Rails 2.3.2 app
I have 2 models:
class Post
has_many :approved_comments, :class_name => 'Comment', :conditions => ['approved => ?', true]
end
class Comment
belongs_to :post
end
For some reason when I try to eager load my comments, I get an error
post = Post.find(:first, :conditions => ["permalink=?", permalink], :includ...
I'm really enjoying Rails (even though I'm generally RESTless), and I enjoy Ruby being very OO. Still, the tendency to make huge ActiveRecord subclasses and huge controllers is quite natural (even if you do use a controller per resource). If you were to create deeper object worlds, where would you put the classes (and modules, I suppose)...
Hi,
I let users embed videos from Youtube, Google, Vimeo etc. I thought about the best and most secure approach (I don't want them to be able to include any flash and I also want to restrict the Videosites to exclude free porn websites etc.).
So I thought the best and easiest thing would be to let the user just copy&paste the URL of t...
I've been asked to devise a website for a small organization (with limited funding) - with internal and external facing sides.
Internally it would allow sharing of documents, a blog, goal setting, more?
Externally it would provide a simple but nicely designed public statement about the company's services.
It may evolve over time.
Sho...
I'm making a fairly basic rails app and I was wondering what's the best way to strip undesirable html from text field (basically, all I'm looking to preserve are links and no more than 2 linebreaks).
Currently, I'm stripping all html and using simpleformat, since it seems to be less overhead than using RDiscount and Markdown/Textile, b...
Hi,
I'm writing a client that consumes a non-REST API (i.e. GET site.com/gettreasurehunts), which requires that I specify all parameters (even the resource ID) in the request's HTTP body as a custom XML document.
I'd like to use Rails and ActiveResource, but I'd be forced to rewrite almost all of ActiveResource's methods.
Is there anot...
I am using Ruby on Rails and have a table that I am trying to sort. The tablesorter jquery plugin and it is properly loaded in my files. I have jquery called in front of it at well. I have this code in my javascript.
$(document).ready(function()
{
$("#myTable").tablesorter({widgets: ['zebra']});
$("#business").tablesorter({sor...
This question will probably only make sense if you know about the whenever gem for creating cron jobs. I have a task in my schedule.rb like
every 1.day, :at => '4am' do
command "cd #{RAILS_ROOT} && rake thinking_sphinx:stop RAILS_ENV=#{RAILS_ENV}"
command "cd #{RAILS_ROOT} && rake thinking_sphinx:index RAILS_ENV=#{RAILS_ENV}"
com...
User is a model. I have 100 users.
I need to present the list of all users so that admin can check or uncheck a user and then do something with it. The problem is that when the the form is submitted then on the server side I get person_1, person_2, person_3 etc. Handling these params could be problematic.
Is there a way so that on the ...
I'm trying to figure out the best way to do error logging in rails using a database (in this case MySQL) as a backend.
It looks like the two popular logging frameworks within rails are the built-in Logger framework and Log4r.
However, as far as I can tell, neither of these support database logging to a database without writing some cus...
I have this rails app that's running on our local intranet, with a thousand regular users. I am looking to integrate it with our email server(MS Exchange). Basically -
1) For each user, the app should fetch any new messages in their inbox from the mail-server, parse it, and file it in the database.
I could implement it with ruby/net-im...
This is a continuation of this question:
Original Question (SO)
The answer to this question involved the following set of models:
class User < ActiveRecord::Base
has_many :friendships
has_many :friends, :through => :friendships #...
end
class Friendship < ActiveRecord::Base
belongs_to :user
belongs_to :friend, :class_name => '...
I'm using jQuery with rails and have the following piece of code
$('#related').html("<%= render :partial => "related_items" %>");
I'm having a problem in the browser where the content of the #related element is only being replaced when there are no line breaks in the partial.
This isn't too much of a big deal, I can place everything ...
I just get started using BDD in Rails application, but I'm not sure what are best practices and workflows? And what other things that I really need for testing for my project such as step definitions, controllers, models, and views? Do I need to test all of those?
...
I am trying to make Authlogic and Facebook Connect (using Facebook) play nice so that you can create an account either the normal registration way or with Facebook connect. I have been able to get the connect to work one way but logging out only loggs out on facebook and not on my site, I have to delete the cookies to make it working. An...