ruby-on-rails

Trying to extend ActionView::Helpers::FormBuilder

Hello I am trying to DRY up some code by moving some logic into the FormBuilder. After reading the documentation about how to select and alternative form builder the logical solution for me seemed to be something like this. In the view <% form_for @event, :builder => TestFormBuilder do |f| %> <%= f.test %> <%= f.submit 'Updat...

ruby on rails regular expression to remove html tags and its content from text

Hi All, I want regular expression in ruby on rails which remove all the html tags and its content from the given text. For example if my text is :-INPUT :- <span id="span_is"><br><br><u><i>Hi</i></u></span> then it should display only OUTPUT should be as follows:- Hi in short i want regular expression or a function which remove...

Ruby on Rails , functionalities having twitter authentication and email authentication (autlogic and 'oath)

Hi Experts, I would like to ask your guidance on how to authenticate using email add/ the basic log-in while having also a twitter log-in, twitter authentication works fine but if having an alternative log-in like using basic sign-up and email log-in part wont work.... any ideas please...? ...

Rails relation select

Hi, I have the following models: class User < ActiveRecord::Base has_many :results, :dependent => :destroy has_many :participants, :dependent => :destroy has_many :courses, :through => :participants end class Course < ActiveRecord::Base has_many :tests, :dependent => :destroy has_many :participants, :dependent => :d...

Rails Counter Cache and its implementation

Hello All, I am trying to get hold of rails counter cache feature but not able to grasp it completely. Let's say that We have 3 models A B C A belongs to B or C depending upon a field key_type and key_id. key_type tells whether A belongs to B or C so if key_type="B" then the record belongs to B otherwise it belongs to C. In my mode...

Deploying Rails app over VPN

You'll have to bear with me as I'm not a Ruby dev, but have inherited a Ruby system. I need to deploy some changes to the app from my repository to the server. I've been instructed to run cap deploy and told that that script will get the latest code from my repository and deploy it to the server. My problem is that I have to VPN to ...

In Rails, what could cause a user to have another user's session?

I have a Rails application using with an authentication system using Restful Authentication without any modification. Users have reported finding themselves logged in as the wrong user. In at least one case it was on their very first page view, never having logged in before. Is it possible their session ids are getting mixed up? Would ...

Radio buttons in Hobo Rails

How can I use radio buttons in a form in Hobo Rails? I want a gender field with two options "Male" and "Female". If I use the default enum_string type it creates drop down select instead of radio buttons. ...

Authlogic's current_user object in models

Hi all! I need to know the ID of the current user in a model: def after_save desc, points=nil, nil if answer_index == daily_question.correct_answer_index desc = I18n.t('daily_question.point_log.description.correct') points=daily_question.points else desc = I18n.t('daily_question.point_log.description.incorrect') ...

Drag and drop components in a website with the help of javascript and rails?

I am looking for a drag and drop components implementation for a website similar to http://www.netvibes.com. So the positions of the components should be saved in database. If any one can help me with any javascript or rails tutorial implementation or guidance for this, that will help a lot. ...

Nested form child only updates if parent changes.

In this video (10 sec) you can see that the nested attribute is only updated if it's parent model is changed. Using rails 3.0.0.beta and full project is on github. Summary of models and form: class Project < ActiveRecord::Base has_many :tasks accepts_nested_attributes_for :tasks end class Task < ActiveRecord::Base belongs_to :p...

Using Administration Dashboard with Declarative Authorization and Authlogic ?

Hello, I use Declarative Authorization and Authlogic and now wants to create a dashboard for the administration. About ActiveScaffold will be an overview of the different controllers are shown. However, I have the problem that I can admin no "admin rights" to the subfolders app/controllers/admin/admin_controller. How can I do that? C...

How to translate this MySQL statement into named_scope method?

"select * from users, awards where (users.id = awards.user_id) and awards.trophy_id not in (select awards.trophy_id from awards where awards.trophy_id = #{trophy.id})" ...

Click to select from a list of tags in jQuery

I'm struggling to find a tag selection UI for a rails app. Ideally it would be something like the selection here on Stackoverflow, or on Delicious or Digg. I want users to be able to select multiple tags with a single click. We're already using jQuery, so it makes sense to use something that takes advantage of that. I've used the sel...

_mask and Rails

So I am trying to get the cancan gem to work with my rails 3 app and I've hit a problem. I tried to copy the code that Ryan Bates (the creator of the gem) used in his screen cast, but I get an error saying that roles_mask is not a method. I figure that the _mask method was removed from Ruby/Rails at some point, and I'm now wondering wh...

translate database fields with rails

hi I know about the built-in I18n in Rails, but how can I select a database field per locale? My model structure is something like this: title #default (englisch) title_de #(german) title_it #(italian) In my template I want to be able to write only <%= @model.title %> and should get the value in the right language. Is there ...

Exclude specific files when pushing to a specific Git repository

Is it possible to exclude specific files (*.ai, *.psd) when pushing to certain repositories with Git? My need comes from trying to use Git for both version control and deployment to Heroku. If I include my graphic assets in the deploy, the slug size is larger than desired. However, I do need to include all project files in my main gith...

Testing custom rails model methods

I have a number of models that store words as a string with each words separated by a space. I have defined model methods to delete and add words to the string and the size or number of words is updated each time accordingly. There is an error somewhere because the size sometimes comes out to be negative. I'm wondering, what is the be...

Ruby on Rails questionnaire tutorial?

Can't find any tutorial for creating a simple questionnaire system on RoR (without using Finite State Machines). I think the Model is simple: Quizzes (have many Questions) Questions (belong to Quizzes, have many Choices, have one Answer) Choices (belong to Questions) Responses (belong to Users, belong to Questions) Users (have many ...

multiple models in Rails with a shared interface

I'm not sure of the best structure for a particular situation in Rails. We have several types of workshops. The administration of the workshops is the same regardless of workshop type, so the data for the workshops is in a single model. We collect feedback from participants about the workshops, and the questionnaire is different for each...