tagged [ruby]
ActiveRecord OR query
ActiveRecord OR query How do you do an OR query in Rails 3 ActiveRecord. All the examples I find just have AND queries. > Edit: method is available since Rails 5. See [ActiveRecord::QueryMethods](http...
- Modified
- 28 Aug at 06:8
link_to method and click event in Rails
link_to method and click event in Rails How do I create a link of this type: using method `link_to` in Rails? I couldn't figure it out from [Rails docs](http://api.rubyonrails.org/classes/ActionView/H...
- Modified
- 29 Dec at 20:51
How to redirect to a 404 in Rails?
How to redirect to a 404 in Rails? I'd like to 'fake' a 404 page in Rails. In PHP, I would just send a header with the error code as such: How is that done with Rails?
- Modified
- 6 Apr at 12:46
Rails how to run rake task
Rails how to run rake task How do I run this rake file in terminal/console? my statistik.rake in lib/tasks
- Modified
- 29 Mar at 01:31
How do I loop over a hash of hashes?
How do I loop over a hash of hashes? I have this hash: How do I access the separate values in the value hash on the loop?
- Modified
- 16 Dec at 10:54
rails simple_form - hidden field - create?
rails simple_form - hidden field - create? How can you have a hidden field with simple form? The following code: results in this error: ``` undefined method `hidden' for #SimpleForm::FormBuilder:0x000...
- Modified
- 27 Dec at 05:3
Remove duplicate elements from array in Ruby
Remove duplicate elements from array in Ruby I have a Ruby array which contains duplicate elements. How can I remove all the duplicate elements from this array while retaining all unique elements with...
- Modified
- 26 Sep at 18:13
In Ruby on Rails is there a way to view the properties of a model
In Ruby on Rails is there a way to view the properties of a model I am using NetBeans to create my first Ruby on Rails application. Is there a way by which I can view all of the properties of a model?...
- Modified
- 18 Sep at 17:25
How do you do relative time in Rails?
How do you do relative time in Rails? I'm writing a Rails application, but can't seem to find how to do relative time, i.e. if given a certain Time class, it can calculate "30 seconds ago" or "2 days ...
- Modified
- 15 Oct at 15:54
How to add 10 days to current time in Rails
How to add 10 days to current time in Rails I tried doing something like but that doesn't work, even though I vaguely remember seeing, and being very impressed, with being able to do something like `2...
- Modified
- 16 Mar at 17:49
Rails DateTime.now without Time
Rails DateTime.now without Time I need to use DateTime.now to grab the current date, and "strip off" the time. For example, this shows what I want: `DateTime.now => Sat, 19 Nov 2011 18:54:13 UTC +00:0...
- Modified
- 19 Nov at 18:55
Internationalizing whole text with markup in Rails 3
Internationalizing whole text with markup in Rails 3 What's the best practice for internationalizing, say, a Terms of Service document in Rails 3? I can think of two options: - - `` None of these seem...
- Modified
- 4 Feb at 08:38
transform time into local time in Ruby on Rails
transform time into local time in Ruby on Rails Right now I have: `Time.strftime("%I:%M%p")` which gives me the `hr:min AM/PM` format which I need. However it's coming back in UTC and I need it local ...
- Modified
- 24 Feb at 22:15
How to chain scope queries with OR instead of AND?
How to chain scope queries with OR instead of AND? I'm using Rails3, ActiveRecord Just wondering how can I chain the scopes with OR statements rather than AND. e.g. That normally returns: but I'd like...
- Modified
- 20 May at 10:50
Write to rails console
Write to rails console When I want to try or debug smthing I run `rails console` and do some stuff there. I can print some text or variables from code by raising exception with `raise "blablabla"`. Ho...
- Modified
- 19 Feb at 15:55
How to read ruby on rails config values from within the application controller
How to read ruby on rails config values from within the application controller If i have a configuration file like this How do I get the value from within my application controller, e.g: ``` # app/con...
- Modified
- 3 Sep at 16:20
How to run a single RSpec test?
How to run a single RSpec test? I have the following file: What command in terminal do I use to run just that spec and in what directory do I run the command? My gem file: ``` # Test ENVIRONMENT GEMS ...
- Modified
- 28 Aug at 10:34
How can I download a file from a URL and save it in Rails?
How can I download a file from a URL and save it in Rails? I have a URL to an image which i want to save locally, so that I can use Paperclip to produce a thumbnail for my application. What's the best...
- Modified
- 11 Jan at 05:41
How to reverse a 'rails generate'
How to reverse a 'rails generate' I want to delete all the files it created and roll back any changes made, but not necessarily to the database, but more to the config files. I'd like to automatically...
- Modified
- 24 Jan at 23:44
How to delete migration files in Rails 3
How to delete migration files in Rails 3 I would like to remove/delete a migration file. How would I go about doing that? I know there are similar questions on here but as an update, is there a better...
- Modified
- 23 Aug at 21:32
rails active record nuances and protecting against injection attacks
rails active record nuances and protecting against injection attacks When I make a query... is there any meaningful difference between using a find_by helper or not? Are there any reasons I'm overlook...
- Modified
- 17 Oct at 15:55
Why do migrations need the table block param?
Why do migrations need the table block param? Why does the ruby on rails migration syntax look like this: And not: Personally I find the second snippet much more readable, are there any reason
- Modified
- 5 Oct at 00:42
Rails ActiveRecord date between
Rails ActiveRecord date between I need to query comments made in one day. The field is part of the standard timestamps, is `created_at`. The selected date is coming from a `date_select`. How can I use...
- Modified
- 6 Jun at 20:14
Testing for empty or nil-value string
Testing for empty or nil-value string I'm trying to set a variable conditionally in Ruby. I need to set it if the variable is nil or empty (0 length string). I've come up with the following: While it ...
- Modified
- 14 Apr at 18:40
Rails formatting date
Rails formatting date I am posting a date to an API and the required format is as follows: I can get the date from the model like so: That returns: How can I use Rails or Ruby to format it like the re...
- Modified
- 7 Dec at 23:39