ruby-on-rails-plugins

Rails 3.1 Mountable Engines : How to use/template it inside another application?

僤鯓⒐⒋嵵緔 提交于 2019-12-04 07:29:45
Let's say I created a mountable engine called 'Soho' that has a controller for 'Users'. I can go to /users/1 to see my user with ID 1. Inside 'Soho', I have a application.html.erb for layout. Now let's assume I want to "blend" my engine 'Soho' in an application called 'Soho_test', and I mount my engine at "/". So, in my host application 'Soho_test', I can also go at /users/1 to see my user with ID 1. This is working. My question is : how can I do in my host application 'Soho_test' to apply the 'Soho_test' application.html.erb to the /users/1 (user profile page) instead of the one in the 'Soho'

Creating WYSIWYG form builder (á la Wufoo) in Rails

[亡魂溺海] 提交于 2019-12-04 06:01:05
I have to add Wufoo-like WYSIWYG form-builder functionality to a Rails webapp. Does anyone know of good resources (gems/engines/plugins/example code) that would help? this is not really an answer to your question, but I still can't add comments unfortunately, due to my reputation level, sorry :) There is exact equivalent of such functionality in Drupal(php) http://drupal.org/project/webform especially useful for contact forms, i.e. clients happy and don't bug me every time they want to adjust or even to add new inquiry form :) Would be nice to have such gem/plugin if any? :P Thanks. I don't

Sqlite3 error after Rails 3 (beta 4) install

China☆狼群 提交于 2019-12-04 03:53:20
问题 After Installing Rails 3, I get the following error regarding Sqlite3 when I try to do a migrate: dlsym(0x1037e5f10, Init_sqlite3_native): symbol not found - /Library/Ruby/Gems/1.8/gems/sqlite3-ruby-1.3.0/lib/sqlite3/sqlite3_native.bundle I am using Snow Leopard, if that makes a difference. 回答1: I faced the same issue. The problem is that your sqlite-ruby interface is not installed properly in your snow leopard. To install that , use the following :- sudo gem install sqlite3-ruby But before

Using jQuery plugins in Rails 3

☆樱花仙子☆ 提交于 2019-12-04 03:04:59
Having finished Hartl's great Rails Tutorial I'm now working my way through the very good jQuery - Novice to Ninja by Castledine and Sharkie. While I've able to include jquery.js and jquery-ui.js in my rails projects, I'm getting stuck when it comes to adding other jQuery plugins. I've figured out that when the plugins are hosted on github, I can import them into my project using the command line and: [my rails app]$ rails install [github URL] The plugin gets successfully imported into the /vendor/plugin/ directory where javascript_include_tag can't find them. This situation prompts 3

Gem-idea: Automatic spam protection with captcha in before_filter when HTTP-method is post,put or delete

喜夏-厌秋 提交于 2019-12-03 21:00:02
I'm thinking about writing an automatic spam protection system (maybe I will write a public gem) for rails. My concept is to include a helper method in application_controller f.e.: class ApplicationController < ActionController::Base automatic_captcha_redirect(:min_time => 30.seconds :limit => 50) ... end Then I want to include automatical a before_filter in every controller, which checks, if the current request is via post, put or delete-method. If the user's last post-request is smaller than :min_time, then the request should be redirected to an captcha-input-page (the posted user-data

Saving the order of associated records in a Rails has_many :through association

試著忘記壹切 提交于 2019-12-03 14:07:09
I'm working on a Rails plugin that includes a way to modify the order of associated records in a has_many :through association. Say we have the following models: class Playlist < ActiveRecord::Base has_many :playlists_songs, :dependent => :destroy has_many :songs, :through => :playlists_songs end class Song < ActiveRecord::Base has_many :playlists_songs, :dependent => :destroy has_many :playlists, :through => :playlists_songs end class PlaylistsSong < ActiveRecord::Base belongs_to :playlist belongs_to :song end If we change the order of a Playlist's Songs (e.g. @playlist.songs.rotate! ), Rails

With paperclip, how can I change the image location to a “:parent_model_id/:id” folder format?

爱⌒轻易说出口 提交于 2019-12-03 13:13:50
问题 Given that I have a Listing model that has many images and each image has one attachment , how can I have the listing_id be part of the folder structure? Like so: system/photos/[listing_id]/:id I know that using :id will output the id of the image record. Here's what I currently have: class Image < ActiveRecord::Base belongs_to :listing #Rails ActiveRecord Relation. An image belongs to a post. # paperclip data has_attached_file :photo, :styles => { :medium => "300x300>", :thumb => "100x100>"

Confused about how to install Rails plugins

倾然丶 夕夏残阳落幕 提交于 2019-12-03 12:27:27
I found an example here showing how to install a Rails plugin. Their example shows this: ./script/plugin install calendar_helper This won't work for me because, confusingly, I don't have anything called plugin in my script directory. All I have is rails : $ ls script/ rails So Rails doesn't come with the script you need to install plugins? You need a plugin to install plugins? That doesn't seem very likely. Is something wrong with my Rails project? You're probably on Rails 3. Replace ./script/plugin with rails plugin. rails plugin install calendar_helper But the other problem is plugins,

acts_as_list with has_and_belongs_to_many relationship

喜你入骨 提交于 2019-12-03 12:08:36
I've found an old plugin called acts_as_habtm_list - but it's for Rails 1.0.0. Is this functionality built in acts_as_list now? I can't seem to find any information on it. Basically, I have an artists_events table - no model. The relationship is handled through those two models specifying :has_and_belongs_to_many How can I specify order in this situation? I'm assuming that you have two models - Artist and Event. You want to have an habtm relationship between them and you want to be able to define an order of events for each artist. Here's my solution. I'm writing this code from my head, but

switching a subdirectory managed by git to a submodule

萝らか妹 提交于 2019-12-03 11:58:19
问题 We used to have a local hack of delayed_job in a Rails app, in vendor/plugins/delayed_job. It was installed as a one-time event and checked into git in the main app repo. Now we decided to fork delayed_job on github and replace the subdirectory by a git submodule, as described e.g. here: http://doblock.com/articles/using-git-submodules-to-manage-plugins-in-rails Before doing that, I simply removed vendor/plugins/delayed_job, without checking it in. Now, despite adding the submodule, git