ruby-on-rails-plugins

Rails - Paperclip validating attachment size when it shouldn't be?

旧街凉风 提交于 2019-12-03 02:35:49
I've got a rails model using Paperclip that looks like this: has_attached_file :image, :styles => { :normal => ['857x392#', :png] }, :url => '/assets/pages/:id/:basename.:extension', :path => ':rails_root/public/assets/pages/:id/:basename.:extension' validates_attachment_size :image, :less_than => 2.megabytes When attempting to create a record of this model without an attachment to upload, the validation error is returned: There were problems with the following fields: * Image file size file size must be between 0 and 2097152 bytes. I've tried passing both :allow_blank => true and :allow_nil =

Rails Plugins [closed]

偶尔善良 提交于 2019-12-03 01:23:37
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . What are some of your favorite rails plugins that you would consider "must haves"? This entry lists some of my favorites that I use in a large majority of my rails applications: My favorite rails plugins 回答1: RESTful Authentication Exception Notification Acts As State Machine Shoulda Account Location I use all

Exception Notification Gem and Rails 3

Deadly 提交于 2019-12-03 01:10:13
问题 I'm trying to get this up and running, but I see "uninitialized constant ExceptionNotifier" whenever I start my server. http://github.com/rails/exception_notification In my Gemfile I have gem "exception_notification", :git => "http://github.com/rails/exception_notification.git", :branch => "master" I've tried putting the configuration as shown in the github readme inside of config/application.rb, config/environment.rb, and config.ru. I replaced "Whatever" with my application name. 回答1: All

Devise within namespace

你离开我真会死。 提交于 2019-12-03 00:55:00
问题 I'm trying to split my rails project in a front-end for regular users and a back-end for admins. Therefore i have created a namespace 'admin' so that i can easily control admin specific controller methods/layouts/authentication in the map admin. I'm using Devise to register/authenticate my admins only. Because it is only used for admins only i'm trying to move Devise to the admin namespace. I could not find exactly what i was looking for in the documentation of Devise but i tried something

How to detect browser type and its version

坚强是说给别人听的谎言 提交于 2019-12-02 22:05:29
how can i detect browser type and its version in Rails. I want to put check on the version of specific browser and if its not required browser version than ask user to upgrade it.. i use below specified command but as its not following a standard pattern am unable to use it. request.env['HTTP_USER_AGENT'] Chrome out put is below Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.205 Safari/534.16 Safari out put is below Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1

Ruby on Rails 3 - Public live chat

核能气质少年 提交于 2019-12-02 19:47:37
I want to create a public live chat application using rails 3. I found some example on rails 2. Any one can tell you a good example / tutorial to develop a live chat application using rails 3. I'd start by checking out Ilya Grigorik's em-synchony + examples and looking at the code for the Hector private chat server gem. I encountered several roadblocks as I tried to implement a public and private chat system in my rails 3 app. I looked at faye, juggernaut, node.js and more. Eventually after trying several approaches I was able to implement a system that works great: 1) I started by following

Rails: Management of read/unread messages

喜夏-厌秋 提交于 2019-12-02 18:55:53
for a forum-like application I need the ability to show each user the unread (new) messages. Is there any Rails plugin/gem for that purpose? Or: Are there any hints to do this job in a efficent way? I'm thinking about an additional database-table storing the unread-status (or read-status?) of every message for every user. But this seems to be brute-force method, perhaps there is a smarter solution... Best wishes, Georg In the meantime I have created a Rails plugin based on my idea above, but with a more improved algorithm. Check it out here: http://github.com/ledermann/unread To whom it may

Get a value of object field inside fields_for loop

霸气de小男生 提交于 2019-12-02 17:55:23
In the following scenario, I need to check the value of the object property in the fields_for loop. <%= f.semantic_fields_for :review_details do |rd| %> <%= rd.input :review_criteria_id, :as=>:hidden %> <% end %> As in the loop, :review_criteria_id is rendered as hidden field, but I have a scenario, where I have to print some more information if it is a specific criteria. How can I get the value of review_criteria_id in the loop. I used: rd.review_criteria_id But since rd is the formtastic object, so I couldn't get the value of :review_crieteria_id . Formtastic adds additional features to the

How do I convert an existing Rails 3 Application into an Engine?

会有一股神秘感。 提交于 2019-12-02 17:35:36
How can I convert the Forum application I've been developing into a Rails Engine, so that it may be embedded inside other applications? What should I add, keep, or remove? Should I offer a way to integrate the models? How do I set up routes and user configuration? How do I package it into a Gem? What should I watch out for? After reading the articles and the documentation, I managed to narrow down my questions: Should I namespace the models? That is, should I keep them in my Engine's module and in the app/models/engine folder? What configuration files in config should I keep around? What about

Render engine within application layout

♀尐吖头ヾ 提交于 2019-12-02 17:30:46
Background I am creating a application that is made up of a core and several modules. The modules are rails engines, and provide the actual functionality as the core itself only acts as a host. The engines are hosted from /lib and mounted at their respective paths. coreApp └──lib ├── module1 ├── module2 └── etc The modules are then mounted like this mount Module1::Engine => "/module1", :as => "module1" mount Module2::Engine => "/module2", :as => "module2" The core is also responsible for handeling the session, although the login itself is done by a module. Problem I have yet to find a great