ruby-on-rails

File upload with rest-client.

Model .. def self.upload_client_document(params) client_document = self.new :uploaded_data => params[:Filedata],:client_id => params[:client_id],:document_name => self.default_document_name,:document_description => self.default_description_name client_document.rename_document_name client_document.save! # RAILS_ROOT + client_docu...

Can Cancan be used to restrict access to specific values for a single model?

I have a Rails 3 application that has Categories. A category can be administered by somebody with the Category Owner role. But the Category Owner should only be able to access Categories that he owns, not others. I can lock down the admin functions using CanCan, but I need to restrict the specific categories themselves. ...

strange inability to require config/boot after upgrading to ruby 1.9.2

I upgraded my ruby to 1.9.2 and now when I try to start up a Rails 2.3.5 app with script/server I get this error: <internal:lib/rubygems/custom_require>:29:in `require': no such file to load -- script/../config/boot (LoadError) from <internal:lib/rubygems/custom_require>:29:in `require' from script/server:2:in `<main>' ...

Alternatives (or ways to speed up) Acts_As_Recommendable plugin for Ruby on Rails

Hi all- I am currently using the Acts_as_recommendable plugin available here. It is using the pearson correlation coefficient to find recommendations, which is pretty much exactly what I want. The problem however is scale. With more than 2000 or so items, the plugin slows considerably (with 5000 items, I see load times of about a min...

What is the proper way to upload a file to another application which providing service for document management ?

Right now i am storing files in public folder. After that i want to upload those file from public folder to another application which providing services for document management. To upload document to another application. They provided link, username and password . Like http://demo.testltd.com/V12345/search.aspx?username=test1&amp;pa...

link_to project index possible with customized routes.rb and without a Named route in Rails?

my routes.rb looks like this map.resources :bookmarks map.connect ':controller/:id/:action' map.connect ':controller/:action' so i can use urls like this http://localhost:3000/bookmarks/Ruby/show but when i try to link from this site to the index site of the project (bookmarks controller and index action) like this link_to "Star...

What is the Rails Way to iterate through multi-step associations in a view?

I have a Rails 3 project with Product. :product has_many :product_properties :product has_many :properties, :through => :product_properties :product_property belongs_to :product :product_property belongs_to :property :property has_many :product_properties :property belongs_to :property_type There is a attribute "sequence" on :proper...

How can I run Ruby specs and/or tests in MacVim without locking up MacVim?

About 6 months ago I switched from TextMate to MacVim for all of my development work, which primarily consists of coding in Ruby, Ruby on Rails and JavaScript. With TextMate, whenever I needed to run a spec or a test, I could just command+R on the test or spec file and another window would open and the results would be displayed with t...

undefined method `to_sym' for #<Tempfile in render :nothing => true

I am responding to a POST from a server that I don't control, and all the params[] come in as Tempfiles - which I can work around. (I am running on thin here at my desktop mac). The whole method works, but at the last line I have: render :nothing => true As there is nothing to render. It is in this render :nothing => true call that rai...

Rails gem rails3-jquery-autocomplete: How do I query multiple fields

I'm using the rails3-jquery-autocomplete gem found here: http://github.com/crowdint/rails3-jquery-autocomplete The instructions are clear for how to query a single attribute of a model and I am able to make that work without a problem. My Person model has two attributes that I would like to combine and query, however. They are first_n...

Authlogic, Namespace and private methods in ApplicationController

Hello, I am troubleshooting why my ApplicationController's methods don't seem to work in my namespaced admin area and it seems like when I'm in a namespace I cannot access my ApplicationController's private methods, is this right? If it is like that, what's the best practise to reuse something like Authlogic's example ApplicationContro...

SQL templating engine to mix SQL with dynamic language? (similar to Ruby's erb)

Has anyone comes across a SQL templating engine which allows one to mix SQL with a dynamic language like Ruby or Python? I'm looking for something similar to Ruby erb templates. For example, in Ruby on Rails you can have various templates for a view: customers.html.erb (html + ruby) customers.js.erb (javascript + ruby) Though I want s...

clever universal form partials in rails

I have a widget for currencies which I use throughout my application. Ie. the user changes the currency from EUR -> USD, or about 13 other currencies. I have a few other use-cases such as dates but this one is the easiest to explain. Currency basically just updates a session variable by calling the currency controller and then uses so...

how so i find using the condtion in ruby

I have this @project.posts.count => 11 @project.articles.count => 5 >> a = @project.articles.map(&:signup_id) => [6, 8, 10, 12, 14] I want to only display the project posts that dont have an id of the following [6, 8, 10, 12, 14]. So i want display the posts that dont have an article.signup_id @project.posts #so reject if id is ...

How make this function html_safe?

Hi! I'm writing helper to render html table header def display_standard_table(columns) content_tag :table do content_tag :thead do content_tag :tr do concat columns.collect { |column| content_tag(:th, 'Header'.html_safe) } end end end end The html output is escaped: <table><thead><tr>&lt;th&gt;Header&...

What is the Rails Way to manage a series of has_many relationships off the same model

I am using Rails 3. The main model is Product :product has_many :images :product has_many :related_products (self-referential) :product has_many :descriptions :product has_many :specifications :product has_many :upc_codes :product has_many :prices You get the idea. I'm trying to determine if I can shoehorn this into a properties mod...

Why is this not rejecting my records

>> a => [6, 8, 10, 12, 14] >> @project.posts(:all, :conditions => [ "id not in (?)", a ]) => [#<Post id: 6,........ Why is this not filtering the POst with id of 6 ...

can rename column size to filesize cause problem in attachment_fu ?

can I rename the columns with attachment_fu ? I am using oracle as my database and size is keyword in oracle. so i don't want to create a column with size name. So is it ok to create a column with filesize instead of size while using attachment_fu ?? ...

Mysql strings only get saved up to about 277 char

Hello, Im using ruby on rails with a mysql db in the back. I realized, that the characters are limited up to about 277 per column entry... How can I increase this? Thanks, Markus ...

Specify reason for denying access with CanCan

I really like the Rails authorization gem CanCan. However, I find myself having multiple conditions on certain privileges, and I'd like to be able to give different error messages to the user, depending on why he or she has been denied access. Does CanCan have a mechanism for such behavior? I'm having trouble finding it. Would I have to...