Rails: Ransack not sorting date | Fixed issues |
- Rails: Ransack not sorting date
- Rails: Triple nested forms example
- Passing params in Rails controller for multiple inputs automatically
- Delayed Job - Force retry later
- How to use same variable across various controllers - ruby on rails
- An error occurred while installing byebug (2.7.0), and Bundler cannot continue
- Executing ruby/perl/python scripts without mentioning complete path in Rails
- no method error on ruby on rails
- How to split geojson data sent from Rails using AJAX
- Rails ActiveRecord relationships for has_and_belongs_to_many
- Rails installation issue on Windows 10. Everything but Rails
- Sending mail through Google smtp in Rails 5
- How to query params in nested attributes writer
- Rails auto-reload! third party service
- Where should I run scheduled background jobs?
- Pass non model parameter to controller action
- ActionView::Template::Error (couldn't find file 'magnific-popup') on Heroku
- Rails: Ransack doesn't search associated models properly
- Rails folder structure
- How to merge multiple and different ActiveRecord query in rails and paginate over the records?
- getting Net::OpenTimeout: execution expired only sometimes
- How to add composite primary keys in db using Rails?
- Rails where query fails when using variable in query
- postgresql configuration missing in vagrant virtualbox installation
- A workaround to pre-populate file_field?
- Value of cookies variable is not passing in another controller when using Mozilla Firefox in Rails
- Rails (bunny gem) RabbitMq : message lost from the queue when using pop function
- methode-missing error in rails when starting a server
- How to check if jsonb column is empty Postgres
- Rails custom action missing required key error
Rails: Ransack not sorting date Posted: 04 Nov 2016 08:15 AM PDT I've decided to add Ransack to my application for searching, but, to be honest, it seems to be really glitchy. On the other hand, this is my first time incorporating a gem, so maybe I'm doing something wrong. My search form allows users to dynamically add and remove search conditions, like this. Here's a few issues. First, my controller code: 1.) The "build_condition" nicely creates one empty, default search box when you go the search page. However, after submitting a search, it meanly adds a second empty search box beneath the one you just searched on. Kind of ugly. Anyone know how to prevent that? 2.) The 'date_entered' sort doesn't actually sort anything. date_entered is of type Date. The search does work if I change it to 'student_name' ... but I want to search by date_entered, not student_name. |
Rails: Triple nested forms example Posted: 04 Nov 2016 08:11 AM PDT I have looked around for weeks trying to find an example of triple nested forms that include all the components, including how to handle form_for with the deeply nested model. Fairly new to Rails, but would love if someone could show post an example of a triple nested form_for for something like Group->Project->Tasks, showing controller, model and view connection. Having a difficult time with the Tasks form_for. Thanks. |
Passing params in Rails controller for multiple inputs automatically Posted: 04 Nov 2016 07:58 AM PDT In my user edit form I have the following HTML: So I have Normally in the controller I would do something like: and the params being: However how do I handle the saving of the roles? And can I just auto-save all the params on the form without having to declare them manually. I tried this: But it didn't work. Is there a way to just save all the params to the correct models? |
Delayed Job - Force retry later Posted: 04 Nov 2016 08:11 AM PDT Is there an idiomatic way, or any way at all, to force a delayed job to retry on its own? I have an automated email model that sometimes fails if a user hasn't assigned a particular attribute to it. However, some users do this within a few hours. We wanted to facilitate a way for the users who fix their data in an appropriate time to have their email retried. However, the way I'm currently implementing it is not working. The goal is to retry 5 times within 6 hours (15min, 1hr, 3hr, 6hr). If the specific issue is the cause of the failure, do something with it, otherwise have Essentially, I want to do is more or less something like so: |
How to use same variable across various controllers - ruby on rails Posted: 04 Nov 2016 07:41 AM PDT I am using ruby 2.3.1 and rails 3.2.1. I need to initialize a variable called In my application i am using more than 30 controllers and only two controllers contains sub-menu, so i need to assign This is my some_controller01.rb some_controller02.rb I tried like this in
I know in c# I can declare the variable as static and access it in any file using object. Like wise how can i declare a variable in |
An error occurred while installing byebug (2.7.0), and Bundler cannot continue Posted: 04 Nov 2016 08:07 AM PDT I am getting following error when i am doing bundle install or bundle udpate I am also getting error If i do and then if i do bundle install or bundle udpate i get same error. I tried removing byebug from gem file but then if i try to go to console, i get here's the gemfile |
Executing ruby/perl/python scripts without mentioning complete path in Rails Posted: 04 Nov 2016 07:26 AM PDT I have nearly 100 ruby/perl/python scripts. I want to execute a script which is chosen from the drop down list in the view of Rails.(I know how to execute non ruby scripts from ruby.) Where is the best place to keep those scripts so that I don't have to mention the complete path to those scripts while executing? |
no method error on ruby on rails Posted: 04 Nov 2016 07:23 AM PDT I'm beginner of rails. what I'm trying to do is making a form which has only title and content and building a database that can save them. This is my migrate file And this is my controller And the error messages are here. I don't know what the reason is. There's title column! And I've executed rake db:migrate command. Please help me! |
How to split geojson data sent from Rails using AJAX Posted: 04 Nov 2016 07:21 AM PDT I've been following this post on how to send geojson from rails using AJAX. I can easily send either dataset and manipulate it in my coffeescript, but I'm stumped on how to break it apart if I send both.
|
Rails ActiveRecord relationships for has_and_belongs_to_many Posted: 04 Nov 2016 07:25 AM PDT What would the correct relationships in Rails be for this setup: I then have the following models: Is this correct? As when I try and access: I get the error: So it seems the relationships are not setup properly. |
Rails installation issue on Windows 10. Everything but Rails Posted: 04 Nov 2016 08:20 AM PDT I've tried to install Ruby on Rails, 3 or 4 different times from different sources. I seem to have everything I need except Rails. When I type "rails --version" it says:
It says I have Ruby 2.2.4 and Node is 6.9.1, but no Rails. I'm using Windows 10. I'd really appreciate any help, thanks!!! |
Sending mail through Google smtp in Rails 5 Posted: 04 Nov 2016 06:57 AM PDT I've done a LOT of digging, and I still haven't been able to find an answer. After signing up with devise, an e-mail gets sent to activate the account. The mail works with my e-mail, and I even got a friend of mine to sign up (after messing with the settings for a while), but after that another person tried to sign up but the e-mail wasn't sent to them, and Google sent me another message saying "someone has your password" again. Here's production.rb I turned access for less secure apps on, and I did the unlock captcha thing for gmail. I also turned on IMAP in my gmail settings. Again, I got one friend to sign up, but a day later someone else tried and the e-mail wasn't sent, and an error showed up on the web page. Someone pleeease heeeeelp |
How to query params in nested attributes writer Posted: 04 Nov 2016 06:59 AM PDT In my nested attributes writer some of my attributes have id's and some don't: I want destroy an object unless its id is included in the attributes array. I don't know how to properly query the attributes, so am doing it like this for now: I'd prefer to avoid creating the id_array and instead accomplish it in one line to match this pseudocode: Having trouble coming up with a query that works on attributes though. |
Rails auto-reload! third party service Posted: 04 Nov 2016 06:49 AM PDT My app is connected to some third-party APIs. I have several APIconnector module-singletons that are initialized only once at application start (initialized means the client is instanciated once with the credentials retrieved from secrets) When I Basically all my connectors include a ServiceConnector module like this one Here is an example of a service implementation I use this pattern that lets me reuse those services outside Rails (eg Capistrano, worker without Rails, etc.). In Rails I would load the services that way I guess that executing Is it possible to add code to be executed after a |
Where should I run scheduled background jobs? Posted: 04 Nov 2016 07:53 AM PDT Here in my company we have our regular application in aws ebs with some background jobs. The problem is, these jobs are starting to get heavier and we were thinking in separate them from the application. The question is: Where should we do it? We were thinking in doing it in aws lambda, but then we would have to port our rails code to python, node or java, which seems to be a lot of work. What are other options for this? Should we just create another ec2 environment for the jobs? Thanks in advance. |
Pass non model parameter to controller action Posted: 04 Nov 2016 06:49 AM PDT How do I pass those arguments which are not of model to a controller? script.rb show.html.erb Here how do I access it here? |
ActionView::Template::Error (couldn't find file 'magnific-popup') on Heroku Posted: 04 Nov 2016 06:40 AM PDT I am working on Actually, application already working fine on Heroku but after some changes pushed then show me error which I tried lots but not find proper solutions. I precomplied already on Heroku manytimes but still not solved it. Anyone have a idea then share it. Thanks |
Rails: Ransack doesn't search associated models properly Posted: 04 Nov 2016 06:24 AM PDT I followed the very useful Ransack Railscast but it doesn't work correctly on nested attributes. I have a student model with a nested model, exams. Exams contain a subject, grade, and type. I can search for a student by the attributes of the student class, or by the attributes of the exams class. So, if I search for all exams of History, it will return all students who have a History exam in their record. Which is good. But suppose I search by students who took both a History exam and an English exam. It always returns zero students, even though many students took both. It will only return true if I search across a single exam -- that is, a history exam with a score of 80. I can't search for two different exams at the same time, even though there are many students who have both exams on in their record. I followed the code exactly from the Railscast. Why doesn't this work the way it should? |
Posted: 04 Nov 2016 06:24 AM PDT I have a script which is using rspec tests for automation of the rails app. I don't want to put the file "automation.rb" in the spec folder or in the lib folder (don't want a gem for this code). My question is: Can we have custom folders in addition to the standard ones in the rails directory structure. Eg. a folder like automation in the root directory of rails app. |
How to merge multiple and different ActiveRecord query in rails and paginate over the records? Posted: 04 Nov 2016 06:35 AM PDT I have two similar tables in rails named as messages and message_histories. Periodically we remove the old data from messages table and drop it in message_histories . Now , I want to generate a report on the count of messages grouped by app_id which is present in message and message_history table . Is there a way to Query [Message & MessageHistory ] Model and paginate on the records . Currently I use the following Step , It looks weird but suggest a better way to do this : |
getting Net::OpenTimeout: execution expired only sometimes Posted: 04 Nov 2016 05:58 AM PDT My rails application sends emails through a gmail account using mailer. Till recently everything was working fine. But now sometimes I get the error as This happens sometimes and sometimes it works. I want to know the reason for this behavior. Is it because of the gmail server having load balancing issues or is it because of some configuration issues in the rails app? |
How to add composite primary keys in db using Rails? Posted: 04 Nov 2016 05:57 AM PDT I'm using Rails 5.0 with Postgresql 9.5 I'm in need to add composite primary keys to my model 'User_achievement' (to link 'User' and 'Achievement' models as you may guess). So I tried using the "composite_primary_keys" gem. I followed all the instructions, nevertheless, the result wasn't like I expected. Seems like it doesn't create pkey in the 'user_achievement' table according to the info by psql tool: Here's models and migrations' code: So should the gem alter db tables? or it influences just the rails' environment? Is there the only way to alter db - to add execute line in migration? |
Rails where query fails when using variable in query Posted: 04 Nov 2016 07:22 AM PDT Can some Rails expert throw some light on this behaviour in Rails 4: The two queries should be identical. Why would one fail and the other not? Thanks! Charlie |
postgresql configuration missing in vagrant virtualbox installation Posted: 04 Nov 2016 05:51 AM PDT I'm by no means web developer, but I've lately tried to get some hang of the systems involved in this mystical field. I've gotten ok'ish grasp on ruby and rails/rake, but apparently setting up existing cloud based front/backend system in local development environment isn't really a piece of cake as I thought it would be :D. So we've got rails backend and ReactJS front. The back is mounted to VirtualBox centos/7 virtual machine with vagrant using ansible cookbook. So far I've got 2 issues and I think both are postgresql related.
I've seem few threads about the 2nd case and they've normally just suggested that I should change the port. However I've tried that and it doesn't seem to matter. Also there isn't really anyone using that port. My local machine is Ubuntu 16.04 with postgres 9.5 installed. The vagrant seems to install the 9.4, but I don't think this matters. Any comments would be appreciated. I've read tons of threads regarding this matter from here and also looked both into vagrant and ansible. The big picture is still quite vague and there's not much documentation about this setup. |
A workaround to pre-populate file_field? Posted: 04 Nov 2016 06:26 AM PDT I don't think you can literally pre-populate the This is what I've tried: index
new server _form model |
Value of cookies variable is not passing in another controller when using Mozilla Firefox in Rails Posted: 04 Nov 2016 07:23 AM PDT I am trying to set a cookies variable in users controller like |
Rails (bunny gem) RabbitMq : message lost from the queue when using pop function Posted: 04 Nov 2016 05:19 AM PDT I am using bunny gem to fetch data from rabbitMQ queue. i am using rabbitMQ "pop" function to get data from the queue and its working fine. My issue is that whenever exception occurs inside the pop block my message is lost from the queue even if i have set manual_ack option set to true. for testing purpose i have manually raised the exception with code Below is my sample code. How to avoid such lost of data from the queue when using pop function of bunny gem? is there alternative to pop function to prevent loss of data. |
methode-missing error in rails when starting a server Posted: 04 Nov 2016 06:34 AM PDT Am new to rails, just going through a tutorial "learn ruby on rails" Have successfully push files/folders to the github repository. I want to start the server with rails server to view the default home page of the rails app on my browser but I keep getting a I am running the command in my project directory "\projects\Rails\blog>",and i have installed all the required gems with the command "bundle install" after specifying Gem version as giving in the tutorial. I have configured Rails to connect to email server ("Gmail") also. The error is as shown in the image below. |
How to check if jsonb column is empty Postgres Posted: 04 Nov 2016 05:20 AM PDT I am having trouble checking when the jsonb column of my table is empty. My column directions when empty has value "{}" Tried the following is there any other way that i am not aware of? Using postgresql 9.6 |
Rails custom action missing required key error Posted: 04 Nov 2016 06:31 AM PDT show.html.erb routes.rb Model
routes.rb But I am getting an error But why do I need a |
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 |
ReplyDeleteAfter reading this blog i very strong in this topics and this blog really helpful to all Ruby on Rails Online Course Hyderabad