ruby-on-rails

How to monkeypatch Issue model in Redmine from a plugin, specifically redmine_task_board

I'm trying to add a custom sort method to the Issue.rb model in Redmine from the redmine_task_board plugin. My commit on github I don't know if this is a lack of knowledge about Rails plugins on my part or something specific I have to do with Redmine. Redmine 0.8.6.stable I want this method so that when I show the Task Board show met...

Need help in highlighting the text in rails

Hi, I have built a free text search engine in rails ,I want to highlight search word in result page where, each word in the phrase may not be adjacent to each other( that is they may be present in any part of the text content). I have tried with highlight method of ActionView::Helpers::TextHelper as <%= highlight(content.body, @search_k...

rails + paperclip: Is a generic "Attachment" model a good idea?

On my application I've several things with attachments on them, using paperclip. Clients have one logo. Stores can have one or more pictures. These pictures, in addition, can have other information such as the date in which they were taken. Products can have one or more pictures of them, categorized (from the font, from the back, etc)....

RSpec: Expectation on model's not working while testing controller

I'm trying to write a functional test. My test looks as following: describe PostsController do it "should create a Post" do Post.should_receive(:new).once post :create, { :post => { :caption => "ThePost", :category => "MyCategory" } } end end My PostsController (a part of it actually) looks as following: PostController < ...

Rails controllers not working

Hi Guys, I've just started on rails, got it all setup on my DreamHost account with Passenger, except the demo controller I've created isn't working. I ran: $ script/generate controller demo index The files are all there, but when I go to http://rails.mysite.com/demo/index I get the 'We're sorry, but something went wrong' message. The...

PrinceXML princely

How can I put the creation date into the footer of my pages? in my css file I have: @bottom-center { content: "www.mysite.de - Page " counter(page) "/" counter(pages) " - " ??? ; } ??? should be the creation date in the fortmat dd.mm.yyyy ...

Ruby on Rails app in root directory?

Hey guys, new to rails, but I have found out how to create an app now through the shell but to create an app using rails appname would give me a url of http://url.com/appname/ but I want my app, to be within the route if you understand me, so it's just http://url.com/login/ or /signup or /play so on? So does anyone have any ideas how to...

Rails on server syntax error?

Hi Everyone, I am trying to get my rails application running on my web server, but when I run the rake db:migrate I get the following error: r oot@oak [/home/macandco/rails_apps/survey_manager]# rake db:migrate (in /home/macandco/rails_apps/survey_manager) == Baseapp: migrating =======================================================...

How do I prevent a form from being resubmitted too quickly in a rails application?

I have made a simple Rails application that allows people to comment on posts. How do I prevent that user from submitting that form over and over again? On reddit.com they only allow newer users to make new posts every ten minutes. How can I do this with my simple blog/commenting system? Any help would be greatly appreciated. Thanks for ...

Rails: using gridify a jqgrid wrapper does not display data

Has someone a working example with sample code. I integrated the plugin as described in http://github.com/linoj/gridify. I see the grid header but no data. i have verified that I am sending data from the controller. Anyone has answers or a complete sample that is download-able? thanks sukanta ...

Rails Modeling: Trying to sort out proper associations for Risk Assessment system

I am trying to implement Rails as a Asset Management/Risk Assessment system. I have been trying to work out the best way to model this. A picture of what I am thinking right now. I would like to automate as much of the treating process as possible. Ideally, someone would fill in the information for a new asset, and rails would fill...

Rails equivalent of respond_to |format| with a straight render

I'm working with ActiveResource a lot so my service models are only using XML. Thus, I have no need for a respond_to block, I literally just render :xml => @model I can't however figure out how to render a 404 header using this. I've had to resort to respond_to, which I think adds a few unnecessary method calls. Here's what I'm using...

Rails fails to return scripts/stylesheets

This only happens on my local machine (Windows 7, Ruby 1.8.7). Occasionally rails will just stop returning my stylesheets/javascript and I'll get gross looking pages. If I navigate directly to those scripts, sometimes they work, and sometimes I get errors like: private method `gsub!' called for #<Class:0x76ff830> What could be causing...

Odd ActiveRecord model dynamic initialization bug in production

I've got an ActiveRecord (2.3.5) model that occasionally exhibits incorrect behavior that appears to be related to a problem in its dynamic initialization. Here's the code: class Widget < ActiveRecord::Base extend ActiveSupport::Memoizable serialize :settings VALID_SETTINGS = %w(show_on_sale show_upcoming show_current show_past) ...

How to copy a file using Paperclip

Does anyone know of a way to copy files with Paperclip using S3 for storage? Before I try to write my own, I just wanted to make sure there wasn't already a way to do this. Thanks ...

Rails has_and_belongs_to_many relationship question

Hello all, I'm sure that this question has been asked somewhere before, as the habtm relationship seems to be very confusing. I have two models, users and promotions. The idea is that a promotion can have many users, and a user can have many promotions. class User < ActiveRecord::Base has_and_belongs_to_many :promotions end class ...

How to build an easy Rails authentication with OpenID and OAuth1.0a-2.0?

Hi, I'am looking for an easy authentication for my users mostly via facebook, but keeping OpenID and other OAuth alternatives as well. For the case if something will go very bad, I will ask my users to optionally provide their email address, which should be obtained via OpenID or OAuth if possible. The same thing is about their name. I ...

ruby on rails 3.0 upgrade

hey, I wanted to upgrade to rails 3.0. i followed the link below http://oscardelben.com/install-rails-3 everything seemed to go smooth but finally.... gokul@gokul-laptop:~/Desktop$ rails -v Rails 2.3.5 what should I do? ...

ActionController::MethodNotAllowed

I have a rails model called 'audioclip'. I orginally created a scaffold with a 'new' action, which I replaced with 'new_record' and 'new_upload', becasue there are two ways to attach audio to this model. Going to /audioclips/new_record doesn't work because it takes 'new_record' as if it was an id. Instead of changing this, I was trying ...

current_user and Comments on Posts - Create another association or loop posts? - Ruby on Rails

I have created a blog application using Ruby on Rails and have just added an authentication piece and it is working nicely. I am now trying to go back through my application to adjust the code such that it only shows information that is associated with a certain user. Currently, Users has_many :posts and Posts has_many :comments. When...