similar to: Best practice to handle this

Displaying 20 results from an estimated 40000 matches similar to: "Best practice to handle this"

2013 Feb 03
4
Create a helper for models and views?
Hi! If I have a method that is useful in both models and in views, where would be the appropriate place to put it? The method in question just takes two dates as strings, tries to parse them and returns all dates in the range between them. It also takes care of the issues when the dates are badly formatted etc etc.. This method is being used in several models (so a simple class method in
2012 Jul 19
20
Rails' inflections are messy
Yesterday, I opened a GitHub Issue<https://github.com/rails/rails/pull/7071> about moving Rails inflections to an initializer. The idea wasn''t received well, understandably, as generating a large initializer with new Rails apps is pretty unappealing. However, the core members seemed open to the discussion of alternatives continuing here. For those of you not in the know,
2013 Jan 29
2
Count entries in postgresql grouped by date
Hi! I have a table with visits with a visited_at: attribute which is a datetime field. They seem to be stored as UTC. Now I want to count all visits each day and return something like: { 2013-01-01: 8, 2013-01-02: 4, 2013-01-07: 9, ... } So, I did it like this which kind of works...: def self.total_grouped_by_day(start_date, end_date) visits = where(visited_at:
2013 Jun 30
1
Sidekiq on Heroku
Hi I want to use Sidekiq to run some jobs in the background. The jobs will be created by the whenever gem (or similar) which creates a Sidekiq worker at a specific time. This worker will in turn create a few hundred Sidekiq jobs. So, I''m using Heroku and wonder if I need to use a separate worker dyno for these jobs? Or can I use, for example, Unicorn to run Sidekiq "inside"
2013 Mar 02
3
Help Radio button
Hi i''m fairly new to ruby on rails and i''m creating a form using simple_form and in one bit i have radio buttons and say i have 3 buttons a,b,c so i want it to be if a is pressed then certain text fields show, and if b is pressed a different set of text fields show and similarly for c. Can anyone help me on this? -- You received this message because you are subscribed to
2013 Jun 09
2
Minitest mock or stub methods
Hi I''m building a small library to use in my Rails app which interacts with a 3rd party API. It fetches artists and tracks. So I have: lib/my_lib.rb lib/my_lib/artist.rb lib/my_lib/track.rb To get an artist I do artist = MyLib::Artist.find("Oasis") Which returns an instance of Artist if it finds (via 3rd party API) it or nil otherwise. Then I can call artist.tracks which
2011 Jul 31
8
Add virtual attribute
Hi! Let''s say I have an app that handles a TODO list. The list has finished and unfinished items. Now I want to add two virtual attributes to the list object; the count of finished and unfinished items in the list. I also need these to be displayed in the json output. How do I achieve that? Best Regards Linus -- You received this message because you are subscribed to the Google
2012 Oct 09
10
Auto refresh the drop-down
I have an option in dropdown like "Add new option" written using grouped_collection_select. And when user clicks on the "Add new option". A pop up dialog appears to add a new value. And when I click create it hits the database and adds the value to the db. But It never updates the dropdown list. Suggest me a way to auto refresh only the current dropdown with the new
2013 Feb 28
2
Create polymorphic resources
Hi I have created a polymorphic association for comments since I need commenting functionality on several models. The issue is that when I create the comment in my Commets#create action, I really don''t know what type the parent is of. So, let''s say I have Foo, Bar and Comment. Comment have this: belongs_to :commentable, polymorphic: true And Foo and Bar both have:
2011 Mar 19
5
Routing issue
Hi! I have two models, artists and songs. I have this in my route file: resources :artists, :path => "ackord" do resources :songs end Which gives me urls like this (I''m using https://github.com/norman/friendly_id to create and manage slugs): example.com/ackord/artistname/songs/songname-id Now I want to remove the /songs part to get a url like this:
2013 Feb 17
5
Where do Gems Live (e.g. CKEditor)
I''m a Rails newbie and I have added the CKEditor Gem which is working okay. To configure the gem though, you have to edit the config file, which is also working when I do that. However, when I push to github and pull to my other computer, the config file is not changed. This lead me to the following broader question: when you use a gem, where does the code go and how can you make sure it
2013 Feb 08
1
Problem with many to many relationship
Hi I''m trying to create a many to many relationship between two models. A User can be associated with many Incidents and vice versa. class User < ActiveRecord::Base include ActiveModel::ForbiddenAttributesProtection has_many :incident_participants, foreign_key: "participant_id" has_many :participated_incidents, through: :incident_participants end class Incident
2012 Oct 12
3
CheckBox with Value and Drop down menu
I am a newbie in Ruby. I would to ask from all the experts in Ruby on how to create a checkbox with value as well as a dropdown menu. I want it like this site http://www.celiac.com/glutenfreemall/advanced_search.php. Their search form is good and I want to learn every aspect in doing it. Hope you can give me a step-by-step tutorial in doing it. Thanks in advance. -- Posted via
2013 Jun 18
1
How to Pass Jquery selected dropdown values and radio button values to controller
Hi, I have an advance search page and its code is as follows - I have written my code like this <div class="container"> <%= form_tag search_index_path, method: :get do %> <%= radio_button_tag ''user_type'', ''customer'' %><p>Customer</p> <%= radio_button_tag ''user_type'',
2013 Oct 30
3
Use of FCKEDITOR as normal text area
Hi all I am trying to use Fckeditor as text area to send mails.here is my code <% remote_form_for :send_sms, :before => "Element.show(''loader'')", :success => "Element.hide(''loader'')" do |sms| %> <div id="news_content_text_field_bg"> <%= fckeditor_textarea :send_sms, :message,:lang =>
2013 Feb 07
11
Rails change default time zone.
Hello everyone, I am using rails 3.2.8. I want to change time zone to New York time. I changed following, but didn''t work #config/application.rb config.time_zone = ''Eastern Time (US & Canada)'' config.active_record.default_timezone = ''Eastern Time (US & Canada)'' If am wrong please clarify. Thank You! -- You received this message
2012 Aug 29
7
custom js in rails project
Hello, I have a rails project with one controller and one action, as simple as posible. And I''m trying to put some custom css and js to my own index.html.erb (not public/index.html.erb), I inluded this on the layout file: layout file: <!DOCTYPE html> <html> <head> <title>Volei</title> <%= stylesheet_link_tag "application", :media =>
2013 Jan 30
1
DropDown onChange event update the table in view
Hi all, I am fairly new to ROR and recently i created an application where i have a combobox when on select the item from combobox i need the table in the view to be updated based on the selection of the item selected in the combobox. I need to do it using javascript , the whole data should be retrived once and when the user selects the item from combo the table data should get updated without
2012 Jan 07
2
set a default value with simple_form
hello anyone know how i can set a default integer value with simple_form, i have code like this below in my view but its not working. <%= f.input :age, :value => ''30'' %> i would like the input box to have the value of 30 by default thanks for any help. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google
2012 Jul 17
24
Static Pages from Railcast
Hi everyone, I need several pages to be static but also modify when requested. I try following the railcast from Ryan at http://railscasts.com/episodes/117-semi-static-pages?view=comments Here what I have done!! rails g scaffold Pages name:string permanentlink:string title:string author:string access_level:string is_published:boolean meta_description:string meta_keyword:string