Ruby on Rails Devise Timeoutable not working | Fixed issues |
- Ruby on Rails Devise Timeoutable not working
- Correct Rails way of using another controller's actions within another controller - subform without nested attributes
- Access Control Allow Origin Error in Ember/Rails file upload to AWS
- How to make Minitest error codes return error message too?
- script/runner:3:in `require': cannot load such file -- commands/runner (LoadError)
- Making a circle with profile pictures inside them
- Rails Concern dynamic relation
- Getting unreadable values in dropdown menu of active admin Rails
- Sendgrid API and User Subscription Logic within a Rails 4 Application
- Error Installing gem `ruby2d` on Ubuntu 14.04
- Custom user page for rails using devise - Using Rails 4 and Ruby - 2.2
- How to pass `self` when invoking a method
- Have one method that will be used in Views, Controllers and Worker in rails app. What is best place to define it?
- How to get grouped_options_for_select to display the selected option on the field when searching?
- How to change html class dynamically in a link_to helper
- rails: running js from rack
- CanCan load_and_authorize_resource does not enforce authorization
- Ruby Gem dependency versions
- Force Read From a delayed Secondary Replica set member
- how to use rails-autoprefixer in Sinatra app?
- Dynamically add file upload field which is not set in any rails model
- Including CSS files in PDF using wicked_pdf helpers
- Can find logs in access.log, Nginx with unicron
- How to allow ActiveAdmin AdminUser to only edit their own password
- Rails - find or create by - for and array?
- mongoid pluck - not returning correct values with default values in model
- Using PdfStamper how i can get the pdf form_field max length value in ruby on rails
- Bundle install works, code runs locally and tests pass on Travis-CI but fails it all fails on AWS
- How to get token from devise_token_auth gem in params rather than header of request?
- How to Use joins to extract data from multiple table in rails 2
Ruby on Rails Devise Timeoutable not working Posted: 01 Apr 2016 07:31 AM PDT I'm having trouble with the Timeoutable component of Devise in my Ruby on Rails application. I am using the remote_authenticatable feature of Devise, and I'm wondering if this is causing the problem. Basically, Devise will timeout after a certain period of inactivity. However, it will not automatically log the user out at this point. Instead, it waits until a call is made to the Rails server (i.e. a controller action is called, such as navigating to a new page), and THEN it redirects the user to the login page. This is problematic for me because the page will contain sensitive data that I do not want others to unintentionally see just because the user stepped away from their computer and forgot to log out. This Stack Overflow answer contains my code: http://stackoverflow.com/a/35464748/4714425 |
Posted: 01 Apr 2016 07:19 AM PDT I'm writing a section of an application which is "jobs to do" and jobs have notes or comments to them. I'm never sure what the right way to use the nested resources views should be - I don't think nested_attributes_for is valid here - I may be wrong. What I want to do is have the main #show action of the job render and at the foot, render the #index of the has_many model (which displays current comments) and then the #new of the has_many model, when I submit it sends via AJAX and adds the new comment to the bottom of the notes/comments panel. I don't think that nested_attributes_for is right here as i'm not really submitting anything on the parent controller. In my mind it makes more sense to render the JobNotesController's #new action from within the JobsController#show so that I could effectively send someone to the raw URL: /jobs/7/jobs_notes/34 And in my mind that way would be more DRY compatible. I'm probably over-complicating it. |
Access Control Allow Origin Error in Ember/Rails file upload to AWS Posted: 01 Apr 2016 07:01 AM PDT I'm trying to setup a file upload functionality to my Ember frontend using the Rails backend to create the correct JSON for authentication with my S3 bucket. I sticking as far as I can with the ember-uploader documentation , especially with the section "Rails Setup" and also this: EmberJs: Upload files directly to S3 with EmberJS and the ember-uploader addon. I created my bucket and changed the CORS configuration as follows: (The Ember frontend uses port 4200) I've got no error messages from the Ember and Rails servers. But the developer console shows: an the upload obviously doesn't occur. My rails gallery controller: Please note that I configured the bucket to be in central Europe since the AWS bucket was also created for the same zone (Frankfurt). Also I set up correctly my environment variables in Rails and checked if they show up in the console. I don't know what I'm missing here since none of the tutorials I am following mentions how to attach the Access Control Allow Origin Header to the request and where. |
How to make Minitest error codes return error message too? Posted: 01 Apr 2016 07:18 AM PDT Getting the following error message. I've got a number of 422 responses each with error messages to help the consumer of my api know what is wrong. |
script/runner:3:in `require': cannot load such file -- commands/runner (LoadError) Posted: 01 Apr 2016 06:39 AM PDT I'm trying to start a class method inside my Rails model with cron and systemd. Unfortunatelly there seems to be somekind of path-problem when cron tries to activate the proper Rails method. Below is my runner-script and the line causing the problem is the 3rd: Complete error message after this is shown below: Or maybe it's because Rails is playing 1st of april's fool's joke on me? |
Making a circle with profile pictures inside them Posted: 01 Apr 2016 07:03 AM PDT I have a website with profile pictures displayed in circles. Some people upload pictures without 1x1 ratios. Currently, the rails/scss mushes the picture into 1x1 raios. I am trying to remove the picture squishing. Is there some way to either crop the longer dimension or to add some gray-space to the shorter dimension using styling? SCSS HTML.SLIM Note: I could just remove either the width or height parameter, but this would make the image display in varying shapes. I am hoping to have it always display in a circle. |
Rails Concern dynamic relation Posted: 01 Apr 2016 07:24 AM PDT I write a gem for rails to have a tiny mongoid shopping cart. in the models it get's implemented by including I have troubles to bring in the How can I make the |
Getting unreadable values in dropdown menu of active admin Rails Posted: 01 Apr 2016 07:16 AM PDT I m getting unreadable values @ dropdown menu in active admin. I have an attribute which has a inclusion of specific values(around 10 values) but when I am making a new object of that class by using active admin... firstly it is showing the unreadable drop down menu second its showing that attribute to be blank even if I m choosing some unreadable value.. plz help My form looks like this (taken from comment on answer): hostel_resident.rb (taken from comment): hostel_resident_controller#create (taken from comment): |
Sendgrid API and User Subscription Logic within a Rails 4 Application Posted: 01 Apr 2016 06:12 AM PDT I came across this post and it seems that I could avoid using the delayed jobs gem which would be preferred. Basis of the application:
The issue: emails are being sent when a ticket is created/updated closed, but there will eventually be 300+ subscribed users receiving emails. I currently have about 15 test users and when a ticket is modified, it seems 15 separate requests are being sent every time: this is quite slow in the browser (ie, the ticket modifier may wait 10+ seconds after the create/update/close button is clicked), but bearable. As more and more users subscribe, this slowness will not be tolerable. Here is the ticket controller in full if you'd like to check it out: I realize it is fairly repetitive and doesn't follow DRY principles, and could certainly be refactored. I'm confused on how to implement (from the linked SO post above) since the categorical logic is in the controller, but the Line 219 of Any input on how I need to modify my logic/implement |
Error Installing gem `ruby2d` on Ubuntu 14.04 Posted: 01 Apr 2016 06:43 AM PDT I am getting following error while try to install ruby2d gem on my Ubuntu 14.04 It would be great if anyone can give me some suggestions! P.S. I had successfully installed Thanks in advance :) |
Custom user page for rails using devise - Using Rails 4 and Ruby - 2.2 Posted: 01 Apr 2016 06:38 AM PDT I am currently using devise for authentication which generates user.rb and controller for user, Welcome page(root page after authentication) which is main page of application where I need to show the total number of user created account in application, number of subject opted by current user and other details of current user. I am unable to route to user page when I am using the same user.rb and user_controller.rb. routes.rb application.html.erb What am I missing ? I am getting the following errors Let me know if I need to provide more informations. Thanks in advance. |
How to pass `self` when invoking a method Posted: 01 Apr 2016 06:57 AM PDT I have a method that sends a message when it triggers something. The signature is: The usage scenario is in the callbacks in active model. When some model is verified, we send a message through the template: We pass Is there a method that passes More concrete examples are below: I share my send method below (In class |
Posted: 01 Apr 2016 05:28 AM PDT In my rails app I have a method that will be used in different Views, Controllers and in different Workers as well so what is best place to define this method such that code would not be get repeated. |
How to get grouped_options_for_select to display the selected option on the field when searching? Posted: 01 Apr 2016 04:57 AM PDT I'm using grouped_options_for_select on my dropdown select field. However, when I select an option, it doesn't stay on the field as a selected option, (after I push the "search" button), but the field jumps to the first option on the list. Search still works correctly, but I would like the field to show what the user was searching for. This is what I tried: It works correctly if I display all the options as such: In the above case the selected option, that is searched, stays 'active' on the list after pushing the "search" button. But I would like to sort the options based on countries, that's why I prefer the first option with grouped_options_for_select. |
How to change html class dynamically in a link_to helper Posted: 01 Apr 2016 04:57 AM PDT I have the following link_to helper: and I would like to be able to change the How can I achieve this? |
Posted: 01 Apr 2016 04:42 AM PDT In rack I'd like to run js response that redirects to a page if the request type is js. I got this far. The How should I invoke the js response to run? |
CanCan load_and_authorize_resource does not enforce authorization Posted: 01 Apr 2016 04:20 AM PDT I have multiple customers in the database and each of them can have multiple admins but I want to keep those customers separate and prevent from viewing each others information. I have added the following code to the ability model: When checking in the console, the abilities are set correctly. Unfortunately even though I have added load_and_authorize_resource in the controller, admin users are able to view pages (such as edit) for other customers. This is not an expected behaviour- could you please tell me if this is a bug? This is how my controller looks like: |
Posted: 01 Apr 2016 04:50 AM PDT I finish my first gem. I want to publish it, but i have dependencies question. My gem has dependency of active_record(~> 4.1); And development_dependencies: rake, bundler, sqlite; How can I determine minimal and maximal versions of rake, bundler, sqlite that will works with my gem? |
Force Read From a delayed Secondary Replica set member Posted: 01 Apr 2016 04:06 AM PDT I have a ruby based application. Objective is to read from a mongo replica set member that is:
Previously, It was noticed that sometimes Moped reads from other secondaries with high latency(remotely present in other data centers) and not from the secondary desired. To resolve the same problem, we have added a delay on remote secondaries. Now I have a fresh analytics application that uses mongoid. Is there a way I could FORCE read from SPECIFIC secondary using mongoid or any other gem? Please suggest |
how to use rails-autoprefixer in Sinatra app? Posted: 01 Apr 2016 06:14 AM PDT I can't make autoprefixer work. It is called, but no result in my css code. There are instructions for Sinatra app here - https://github.com/ai/autoprefixer-rails application.rb I looked into gem source and found such examples: or |
Dynamically add file upload field which is not set in any rails model Posted: 01 Apr 2016 03:57 AM PDT I have a dynamic file upload option, where user can drag&drop multiple times to the form named Am storing these custom fields values in separate model named
What should i add in model file for this
|
Including CSS files in PDF using wicked_pdf helpers Posted: 01 Apr 2016 04:19 AM PDT I am successfully loading CSS files in my PDF file using wicked_pdf gem helpers: This works great in development, however when i deploy in production the pdf CSS file is not correctly imported. Also note that the file is "pdf.scss.erb" and not just "pdf.css". I am not sure how to fix this problem. Looking at the server logs, i do not see any missed file warnings. |
Can find logs in access.log, Nginx with unicron Posted: 01 Apr 2016 03:34 AM PDT sudo vi /etc/nginx/sites-available/default file nginx service and unicorn server is running But i can not see any log in access.log and application us not accessible from the browser. Unicron.rb (rails server is ruuning) |
How to allow ActiveAdmin AdminUser to only edit their own password Posted: 01 Apr 2016 03:27 AM PDT Working with ActiveAdmin and I want to restrict AdminUser from editing other people's information. How can I go about doing this? This is as far as I've gotten. I don't know how to properly define the allow_to_edit? method. I expect it to be something like this: |
Rails - find or create by - for and array? Posted: 01 Apr 2016 03:34 AM PDT I'm trying to do a Now, if I do it will only check for the first title logic with a But I want to do it for ANY titles .. any idea? Thanks ! |
mongoid pluck - not returning correct values with default values in model Posted: 01 Apr 2016 04:00 AM PDT I have a User model where there is a department field which has a default value of "Engineering". This field was introduced 2 months after our website went live,and since its mongo, there was no migration. When I try to get the object using where, correct value is returned However, if I try to pluck values, it returns nil and not the default value. returns I researched a bit and came across this blog post http://ahmadsherif.com/blog/2013/01/29/mongoid-default-fields-can-give-you-hard-time/ I think I am facing the same issue. Is there any work around for this? I chose to go with pluck because it's not memory intensive and saves time. |
Using PdfStamper how i can get the pdf form_field max length value in ruby on rails Posted: 01 Apr 2016 03:16 AM PDT By using Rjb gem i want to read pdf require 'rubygems' require 'rjb' Ping::JavaVm.load PdfReader = Rjb::import('com.lowagie.text.pdf.PdfReader') PdfStamper = Rjb::import('com.lowagie.text.pdf.PdfStamper') @pdf_reader = PdfReader.new(filename) #this will read a pdf @pdf_reader.getNumberOfPages #will get no.of pages To get all field_names from pdf this is the method writtendef form_field_names my question is how can i get pdf form_field limit(max_length) value. |
Bundle install works, code runs locally and tests pass on Travis-CI but fails it all fails on AWS Posted: 01 Apr 2016 03:11 AM PDT My current Rails (4.2.6) project works fine running on my local machine either with There is no question that The command used to run the app on AWS is: ( Running the app locally with it runs with no issues. Any clues welcomed. |
How to get token from devise_token_auth gem in params rather than header of request? Posted: 01 Apr 2016 03:04 AM PDT I am using devise_token_auth gem for creating an API. This gem after sign_in sends token, uid etc through header. Also on each request to api the authenticate user is checked by checking token in header. How can I authenticate_user by sending token and uid by url params instead of request header? |
How to Use joins to extract data from multiple table in rails 2 Posted: 01 Apr 2016 02:57 AM PDT Now i am extracting report builder data from the above code. But I need to learn how to use joins in rails 2. Please help me out. Thank You |
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 |
Excellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. Ruby on Rails Online Training Hyderabad
ReplyDelete