Order by count of a model's association with a particular attribute | Fixed issues |
- Order by count of a model's association with a particular attribute
- jQuery: Adding appropriate structure to DOM (Rails 4)
- Rails 4 - Simple Form - Jquery - How to add a class to an option in a selectbox
- Javasript does not work after j rendering a view
- Rails: Test case is failing when running all the test cases simultaneously in rubymine
- How to download each zip file from a url and unpack using rails
- LoadError: incompatible library version - /usr/local/rvm/gems/ruby-2.2.1/gems/nokogiri-1.6.8.1/lib/nokogiri/nokogiri.so
- Rails Controller: How to return list of specific objects?
- Rails nested form fields_for doubled in edit
- NoMethodError: undefined method `merge!' for "branch_name":String
- Ruby on Rails gem install bundler
- Can we extract information from resume means .pdf file or word file and excel file in rails
- Create rails routes only for localhost
- Same session is used in rails 2.3.2 App before and after login to the App
- How do I DRY-ly handle multiple upload types with Carrierwave?
- How to order table with title including numbers?
- Structure rails association[user -> one review -> single model]
- Railsapp Fails To Bind -b 0.0.0.0
- Rails 4, SQ Lite 3: Access model through model without an association
- Strange slow page loading or something similar. Bootstrap
- Rails Composite Keys - Setting up models and assocs
- LoadError: cannot load such file -- active_resource
- Sidekiq logs show job ID instead of job name
- Getting multiple buttons for the same action
- if/else in controller and view Rails
- How can I do something like this with ruby arrays
- Ruby on Rails - Add limit, order and sum on File.open
- Paperclip and pure attachment model
- Google::Apis::AuthorizationError: Unauthorized
- Is it possible to use JS code with in ruby code?
Order by count of a model's association with a particular attribute Posted: 18 Oct 2016 07:59 AM PDT Say I have the two models 'Users' and 'Appointments' where a user has_many appointments. An appointment can be of two different types: typeA and typeB. How can I write a query to order the users by the amount of typeB appointments they have? I've looked into counter_cache but it seems to just count the number of the association (so in this case the number of appointments a user would have) and does not allow for the counting of a particular type of appointment. Any help would be much appreciated! |
jQuery: Adding appropriate structure to DOM (Rails 4) Posted: 18 Oct 2016 07:20 AM PDT I've got a My Code: _notification (haml) _notifications (haml) Controller jQuery Any help is appreciated! If you need additional information, please tell me. |
Rails 4 - Simple Form - Jquery - How to add a class to an option in a selectbox Posted: 18 Oct 2016 07:50 AM PDT I am so confused - your help would be much appreciated. Could one kindly tell me how to add a class to a specific option in a select box. As per the image, i would like to add a class only to the option: _form.html.erb i tried the below but no luck: |
Javasript does not work after j rendering a view Posted: 18 Oct 2016 07:40 AM PDT When I dynamically update content to a page using a remote call and a *js.erb file like this: add_content.js.erb To render a view like this: _content.html.erb With an javasript file like this: application.js ... the javascript slideToggle() is not executed. When I do in any view (without js.erb) everything works as expected and slideToggle() works. This is just a quick example to keep it simple, it is not related to slideToggle, even alert("...") etc. will not work. So my question is why is javascript not executed? Is this related to any loading order? Do I need to re-initialize something? |
Rails: Test case is failing when running all the test cases simultaneously in rubymine Posted: 18 Oct 2016 07:14 AM PDT I am running test case with rubymine. whenever i run individual test case it works and But one of my test case is failed whenever i run all the test cases simultaneously. Below is the error that i am getting. |
How to download each zip file from a url and unpack using rails Posted: 18 Oct 2016 07:40 AM PDT Right now I have a URL which is populated with a list of .zip files in the browser. I am trying to use rails to download the files and then open them using But the |
Posted: 18 Oct 2016 06:51 AM PDT When I try to run rake db:migrate it's showing below error -
Can Anybody assist me on this ? |
Rails Controller: How to return list of specific objects? Posted: 18 Oct 2016 06:54 AM PDT I want to set my @users variable to a specific list of users (whose id's are specified in a file). This is my controller: The commented line throws an error, I think because @users isn't an array, but something else, and I'm not sure what I'm supposed to do. total_entries is defined from the will_paginate gem |
Rails nested form fields_for doubled in edit Posted: 18 Oct 2016 06:37 AM PDT I'm trying to create a form where users can see a list of their friends and add or remove friends from lists (sort of like facebook's groups). For the create list view, I can get the form working properly, but for the edit view I'm having trouble with check_box syntax and fields_for. new.html.erb edit.html.erb new.html.erb renders and saves the selected items correctly, but I can't figure out how to write the edit form so that it doesn't iterate through the collection once for each item in the collection (both with collection_check_boxes and the form as written in new.html.erb). Trying in the edit form just passes the string "id" as params rather than pulling the id of each member in the collection, and I'm not sure how to pull the individual item's name/id without iterating over the collection, which goes back to the multiple renders problem. I'm using cocoon elsewhere in the project, but for this I'd rather present the user a list of all options and allow them to check a box for each one, rather than having to manually add each item on the list. If there is a way to do it with cocoon, I'd be happy to hear it. |
NoMethodError: undefined method `merge!' for "branch_name":String Posted: 18 Oct 2016 06:03 AM PDT I using a gem TinyBucket for retriving commit messages from BitBucket: When I was trying to retrieve commit messages from a particular branch by looping all the commits of the branch as mentioned in the documentation. Documentation: My code: Error message after that loop: Can someone please explain how should I have to send branch name for the options argument to retrieve individual commit messages? |
Ruby on Rails gem install bundler Posted: 18 Oct 2016 05:48 AM PDT Please help gem install bundler, here is why: Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed. Here's the error (Git Bash/Windows 8.1 64-Bit): Thanks |
Can we extract information from resume means .pdf file or word file and excel file in rails Posted: 18 Oct 2016 06:22 AM PDT I have a resume and I want to upload or drag and drop from my local system, at that time I want to extract some information from resume ( .pdf file, word file, excel file) like name, email, contact number, etc. It is possible to extract information from file, then automatic signup. Please post answer properly, I have tried so many times.. |
Create rails routes only for localhost Posted: 18 Oct 2016 06:42 AM PDT I'd like certain rails routes to only be accessible from localhost. In other words if you attempted to access that url from a non localhost connection you would be given a response equivalent to the route not existing. Optimally some way of specifying routes as local in the routes.rb itself would be the cleanest solution but if there is some way to filter the request later at the controller level for example thats okay too. |
Same session is used in rails 2.3.2 App before and after login to the App Posted: 18 Oct 2016 05:00 AM PDT We build a rails 2.3.2 app and has login/logout mechanism using rails session/cookies to log in (not using device gem). After log out, we are resetting the session by using rails reset_session which will drop the session data and create a new session. Created session will be available in a browser (cookies[_session_id]) and after successful login (username-password), the same session is used in the application. Question
I don't want to build this by using device gem or any other gem. Attached screenshot, please check and give me solutions. |
How do I DRY-ly handle multiple upload types with Carrierwave? Posted: 18 Oct 2016 05:26 AM PDT I want to allow my users to be able to upload videos, documents & images to s3. I was thinking that rather than having a model for each and then having 3 different uploader classes, I would just have 1 generic uploader and just whitelist all of those filetypes. But I am not sure if that's the best approach, from a security perspective? Also, there may be small variations with each type. For instance, with What's the most Rails/DRY-way to approach this? |
How to order table with title including numbers? Posted: 18 Oct 2016 05:35 AM PDT Titles in my table looks like that: And I want to order them like below: When I use How to solve this issue? |
Structure rails association[user -> one review -> single model] Posted: 18 Oct 2016 05:16 AM PDT I have 3 models user, app and review Current my models have the following associations User -> Review -> App -> This allow user to create multiple reviews on a simple app model My question: How to structure my models so that user can add only one review in a single app model? How to ensure that user can not add review to app he/she created? |
Railsapp Fails To Bind -b 0.0.0.0 Posted: 18 Oct 2016 04:41 AM PDT rails s -b /usr/lib/ruby/vendor_ruby/thor/base.rb:483:in |
Rails 4, SQ Lite 3: Access model through model without an association Posted: 18 Oct 2016 06:26 AM PDT I've got two tables: In this example I've got an item object Thanks in advance for any help! |
Strange slow page loading or something similar. Bootstrap Posted: 18 Oct 2016 04:18 AM PDT so I just pushed my page to heroku: https://stark-dawn-83245.herokuapp.com/ and if I open it, click on photo, try to log in or do some kind of stuff - pages load with strange flashy style. You can see it yourself. This is not happening on my local host. Can someone please explain to me what is happening? Or at least point me to some documentation about this kind of stuff. |
Rails Composite Keys - Setting up models and assocs Posted: 18 Oct 2016 05:05 AM PDT I'm using Rails Composite Keys for the first time and even though I've read the docs, I'm still unsure how to set up the models correctly. An Activity can be Scheduled by a Provider. I want a join table that tracks I've got this for my composite key as it's own model. Is this right? This for the db migration: How do I then get new entries on the join table as Schedules are created? Do I put only (Also - is this the correct use case for composite keys in the first place?!) Thanks in advance! |
LoadError: cannot load such file -- active_resource Posted: 18 Oct 2016 06:10 AM PDT I have two applications named as 'Book' and 'Inventory' respectively. My 'Book' app is running on 3000 port & 'Inventory' app is running on 4000 port. I have 'book' model in 'Book' app and 'inventory' model in 'Inventory' app. In my 'Book' app I have created inventory.rb file inside app/models folder as below In gemfile I have included : When I am trying to access Inventory model from my 'Book' app console, I am getting below error Or when I am trying I am getting the same error. |
Sidekiq logs show job ID instead of job name Posted: 18 Oct 2016 07:30 AM PDT I have a Rails application that runs some background jobs via ActiveJob and Sidekiq. The sidekiq logs in both the terminal and the log file show the following: Is there some way to show the class names of the jobs here similar to how logs work for a regular Sidekiq Worker? Update: Here is how a Sidekiq worker logs: |
Getting multiple buttons for the same action Posted: 18 Oct 2016 05:43 AM PDT I have a blog rails app where users can comment on an article and the article author can message the user directly from the comment for which i have added a send message button, i am using mailbox for getting the message option, everything is working but the problem is when there are multiple comments the message button also get multiplied, but i don't want that what i am trying to have is one message button for each comment. This is what am getting right now: my code |
if/else in controller and view Rails Posted: 18 Oct 2016 04:47 AM PDT I have an app that I am integrating Bitcoin into using BlockIo API. When a user wants to make a payment, a new Bitcoin address is created for them and saved on the db, and after they make a payment the the amount is also saved, and that amount is retrieved from the API. I need assistance with the syntax or proper way to get the conditional statement working. To generate and save a new Bitcoin address in the controller the code is: I want to create a conditional statement that will display the already generated bitcoin address if the amount ( The attributes for the Payment model/controller are What I have thus far is: But the above code is not working, as it does not generate a new address when I update last Payments' amount to a bigger amount via console. And I am also not sure how to display these results in the view, as I have the following: Send your Bitcoins to: I have checked the Rails guides and have come thus far, any comments or assistance will be greatly appreciated, I need assistance with syntax and making the above conditions to work. |
How can I do something like this with ruby arrays Posted: 18 Oct 2016 04:44 AM PDT I have an user array like this: here first element is user_id and second element is text which is specific to user_id in the same array. Now I am trying to have user object from instead of ids in array like these. I am trying not to loop the array and hit the db thousand times for thousands user. |
Ruby on Rails - Add limit, order and sum on File.open Posted: 18 Oct 2016 04:03 AM PDT In my application I have a This is what i have so far: I can I tried: and When I try these I get error: Is it also possible to |
Paperclip and pure attachment model Posted: 18 Oct 2016 06:07 AM PDT In my Rails application I want to have a simple file storage. This leads me to creating an I'm using Paperclip so I finished with this: and this: Because of that, I need to write not nice things like or Is there a better way to do this or is my way good enough? |
Google::Apis::AuthorizationError: Unauthorized Posted: 18 Oct 2016 03:34 AM PDT Recently i have errors authenticating subsequent requests to Google Calendar API. this is the code i had so far and it worked. But not it stopped and it throws an "unauthorized" message. I am using latest google-api-client gem. I have tried these solutions below creating a class of the above solution solved another error "Missing token endpoint URI" but it does not work for Google::Apis::CalendarV3::CalendarService.new -> only with Google::Apis::Oauth2V2::Oauth2Service.new Next i tried this which again is not working. Any help is welcomed! |
Is it possible to use JS code with in ruby code? Posted: 18 Oct 2016 03:40 AM PDT I am created Rail application with erb views. I want to use some JS code with in ruby code like following I want to query based on user selected value. How to replace "this.id" used above and how to insert js code instead of "this.id" ? |
You are subscribed to email updates from Newest questions tagged ruby-on-rails - Stack Overflow. To stop receiving these emails, you may unsubscribe now. | Email delivery powered by Google |
Google Inc., 1600 Amphitheatre Parkway, Mountain View, CA 94043, United States |
No comments:
Post a Comment