Questions for ruby-on-rails-3


Switching from submit form to remove form using Ajax in Rails 3 app

Using an <% if/else/elsif/end %> statement, I detect whether an object exists in a User's profile in my Rails 3 app. Depending on the object's existence, I render one of two forms:

Why does this before_filter not execute?

So in my ClientsController.rb I have a before filter that does the following:

friendly_id and routes.rb - rails

I'm currently using friendly_id gem in rails and noticed that if someone names a post "About" that it overwrites the /about path that I have assigned to a static page in my routes.rb file.

Rails displaying images from a belongs_to model

I need to display multiple images for a a car from a separate linked table, i have the both models sorted with the belongs_to and has_many but on the main car page i need to show images from the li...

Compare in Rails but ignore year?

I have the following code in my Rails 3 application:

How should I model these relationships?

I have a post model. Each post has a title and many snippets.

Changing my 'seed' file - Rails

I have already seeded my user into the database, but now I would like to change one of those fields. It seems, like the migrations, I cannot just edit the file and run rake db:seed. That doesnt see...

Fetch COUNT(column) as an integer in a query with group by in Rails 3

I have 2 models Category and Article related like this:

Rails - Show all models that belongs_to this User

If I have a User that has_many :problems, assuming I have set up the necessary association between User and Problem , how can I do something like:

Rails 3 multiple parameter filtering using scopes

Trying to do a basic filter in rails 3 using the url params. I'd like to have a white list of params that can be filtered by, and return all the items that match. I've set up some scopes (with many...

Kaminari pagination, how to get the number of the current page?

I am using Kaminari to paginate some results from a db query.

How to show base errors on active_admin gem

In the admin area, how do i go about and show the base errors (errors not specific to a field?). Ideally i would like to do this for all models.

Rails Devise LDAP Error: NoMethodError in Devise::SessionsController#create

My team has setup my ruby on rails app to work with devise ldap. Whenever a user logs in for the first time, it creates a new entry in the Users model and works completely fine. But whenever a user...

Rails mysql update

I'm pretty new to Ruby on Rails, I came from PHP and i've realised it's not just as simple as getting syntax down, there's a lot of good structure practices to take on board too.

How to replace authentication system for Devise in Rails?

I have an authentication system made by hand with all the models and methods for sign in, etc. How hard is it to replace all that system for Devise? I see Devise creates the models and that but in ...

rails 3 - Securing an app with SSL

I have a rails 3 app hosted on heroku which contains sensitive data which is why i want to implement SSL. The info I learned from google searching doesn't exactly match my use case as I want to SSL...

Update a boolean field in db using link_to

I have boolean field in the database, how can I update it in rails using link_to. I want to have two link_to commands. One for true another for false.

why am I getting a mass assignment error when my column is on my attr_accessible list

There are several related questions to this one. But none of the answers address my situation.

Nic Edit : Bullet point in not working

I have used ' Nic Edit ' in my rails project .

Can't connect Ruby on Rails to remote mysql database

I'm trying to connect my rails 3 app to a mysql database hosted on a godaddy server. I am able to connect remotely using a mysql client, but not when I run the applicaton. I was able to connect on a

using Rails root in seeds.rb

In my seeds.rb, I'm doing some file upload cleanup and want to access RAILS_ROOT but doesn't seem to work. Calling:

How to initialize custom ActiveModel Validators in Rails 3+ app from within a Rails Engine

I'm trying to load some custom Validators from a Rails Engine but my application keeps failing due to the validator not being recognized.

Rails default image absolute URL

I have a newbie question:

Devise fields inside a password table

Is that possible to setup Devise gem easily with every of its fields inside a passwords table, which is mapped with a Password model belonging to a User model (having just an email field)?

rails pass variable to model from controller not working

Im trying to pass a variable from controller to my form to no avail.

missing partial when putting a model in another model

I have never seen an error like this, so I don't even know what information of my app to share with you. I am putting an 'address' model inside a 'customer model'. Here is the error. (edit)I am using

Capybara & Rspec: How can I always test for the layout so I don't have to keep rewriting the code for it?

I'm trying to stick to DRY ways of doing things with my testing. I have two layouts, public and application that show certain links and css depending on if a user is signed in or not. I'm wondering...

Render a show view html with some restrictions

I want to create a random selection generator, which should be called using a button<%= button_to("Randomize someting to do!", {:action => "random_task"}) %>

Getting Action Mailer + Devise to play together nicely

So I followed the guides - steps 1 - 2.1.3.

Virtual columns in a model

Is it possible to add a virtual column to a model (not virtual attribute!)?

how do you stub a that happens inside a block?

How do I stub a call so that it returns what I want it to? The following does not work.

Rails sort entries based on attributes of related model

I have a strange scenario: I would like to order all posts P by the time at which P's creator and the current user became friends.

Compare object attributes with array of objects Ruby on Rails

I have an object that I want to compare with an array of objects. If two specific attributes are equal I want to stop the loop. How can I do that, or how can I do this in some better Rails way?

Paperclip is processing attachments even when they don't pass validation?

I have a model that uses paperclips for image attachments

How does Rails populate the “model_type” field for polymorphic associations?

I have an Activity model. It belongs_to :parent, :polymorphic => true.

Ordering by a related classes created_at in Rails

I've got a model User with a related class (User has_many Posts, Post belongs_to User). I want to display Users in a list, with those who have posted most recently at the top. So basically I want...

What is the black dot beside a jquery sortable element?

I'm using JQuery sortable for the first time, and I have a sortable list of elements all working ok (widgets, with a header and some internal form etc workings).

Why do date helpers not work in Rails console?

I have a datetime attribute on a record:

Example for sending a mail manually in rails

I have a web app and i want to add compose mail function so that the users can send the mail to others. I have searched for it and found only the confirmation mail sending after registration but i ...

rail ajax remote form to update text field upon submission

All I want to do is update a text field on my page with a value when my Rails remote form is submitted.

Rails: making a string the primary key in Rails 3

I'm trying to recreate a Sinatra app (using a recipe from a book) into Rails. The Sinatra app uses data_mapper which allows you to set the string as a primary key using using :key => true

How to apply abilities to a non-restful controller in cancan

I'm new to rails and for the life of me I don't "get" cancan.

Having trouble using Ajax to update my div (Rails 3)

I have a form that the user will use to enter in the title of a book, that I will pass into an external book search API, then I want to display the book results right underneath without reloading the

Get yesterday's date

This may be an obvious question but im new to ruby and I've spent ages trying to get yesterdays date for a cucumber test that checks a url that includes yesterday's date. for example:

Auto-removing all newlines from Haml output

I'm using Haml in a Rails 3 app, and its newlines drive me nuts! For example,

Select menus in Rails 3?

I have the following code in my Rails 3 application, it's supposed to be displaying a select box with each asset_type record:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.