Rails more than one skip_before_action | Fixed issues |
- Rails more than one skip_before_action
- Getting associated model attributes using strings
- Proper use of polymorphic association for reports
- Passing custom arguments to Sidetiq
- rspec tests in docker showing database transactions
- Ruby on Rails, Select Users with age range from Active Record
- Unicorn, can't restart: "rack and Rack::Builder must be available for processing config.ru"
- can we manage multiple shopify key in one application?
- Searchkick - how to update mappings and settings (rails)
- Why is my RSpec not loading Devise::Test::ControllerHelpers?
- Rails Devise token and cookie session at same time
- Rails simple_form with multi belongs_to association
- Ruby: why use # not /?
- How can I use Twitter API with Ruby on Rails to retreive tweets from a users follower?
- Ruby on rails application with single http endpoint
- 'rails server' returns error with mysql 5.7.13 on osx elcapitan
- Execute JS every time on the event of turbolinks load in Rails 5 app
- Start MySQL when Rails server gets started?
- Ruby on Rails: Optimising multiple http requests to another server
- Rails app, dashboard routes
- Ruby Rails - Where to start my understanding
- Correctly filled fields should stay filled after error (Angular)
- How to develop new features for rails app without affecting existing website
- Rails database migration fails with “duplicate column name: email”
- Using Appscript with Rails
- How to redirect in ruby on rails app from old sites url
- Command to start rails server when using Puma + Nginx
- How to call Rails ActiveModel.some_class_method from external thread without of connections broking?
- Value not being persisted on form error
- Coffee script event not firing - why not?
Rails more than one skip_before_action Posted: 17 Jul 2016 07:51 AM PDT I want to do more than one skip_bevore_action tried this: but the :user_is_provider function isn't called yet. The function is in application_controller.rb Thanks |
Getting associated model attributes using strings Posted: 17 Jul 2016 07:45 AM PDT I am building a custom method and i want to access attributes by using strings. for example While this works, when i try to get associated attribute values its not working. example: can someone point me in the right direction here? |
Proper use of polymorphic association for reports Posted: 17 Jul 2016 07:42 AM PDT I have a How should I best set up my models/schema to retrieve all reports for the category by using If I do something like that I would have to use a hacky method to retrieve them: What's the proper way? |
Passing custom arguments to Sidetiq Posted: 17 Jul 2016 07:32 AM PDT I have a Rails app that requires the user to pass in input that defines how frequently an action is scheduled (e.g one month, three months, six months, etc.) I'm using Sidekiq to run backup jobs, and integrated Sidetiq for the scheduling. As it turns out (something I realized only after integrating it fully), Sidetiq has problems with recurring tasks that initially require custom input. It will run fine the first time, but when it comes up to run three months later, the arguments the method has are (time_last_run, time_of_next_run) and this is a problem for me because I need some user details passed into the recurring action. This is discussed by Sidetiq's author in this issue from a few years ago: https://github.com/tobiassvn/sidetiq/issues/37 This leaves me rather lost. This is my first Rails app, and I'm not sure how else to perform recurring background tasks with user input. As you can see, the Sidetiq issue still hasn't been resolved, and I'm not sure of any valid alternatives. Does anyone know how I can write a workaround for this? Put another way, how else could I implement this functionality (with or without Sidetiq)? |
rspec tests in docker showing database transactions Posted: 17 Jul 2016 07:20 AM PDT I'm developing a rails app with docker compose and 4 different services: the app, postgres, redis and sidekiq. my problem is that I've tried running this with |
Ruby on Rails, Select Users with age range from Active Record Posted: 17 Jul 2016 07:11 AM PDT User.rb In the console: I'd be able to do the following: I'm stuck at the point how to get the value from age (class method) into the where call |
Unicorn, can't restart: "rack and Rack::Builder must be available for processing config.ru" Posted: 17 Jul 2016 06:52 AM PDT I have an Ubuntu 14.04 server with nginx and unicorn. I have deployed a Rails application with capistrano to When trying to restart unicorn with I'm getting a 502 from nginx when trying to access the site in my browser. Here's my /etc/default/unicorn file: Here's my /etc/unicorn.conf file: Any Ideas? I feel like I have tried everything. |
can we manage multiple shopify key in one application? Posted: 17 Jul 2016 06:50 AM PDT We want to use multiple Shopify API keys in one shopify rails application and switch these API key run time. We are working on to increase API call by help to multiple API calls. Because of each API key have some limitation calls like 40 call at time. |
Searchkick - how to update mappings and settings (rails) Posted: 17 Jul 2016 06:45 AM PDT I have a rails application and around 90k products in my database. I updated the model settings and mappings and need to update these in elasticsearch. When I call Product.reindex, I get a timeout error (Faraday::TimeoutError: Net::ReadTimeout) after 10seconds (I am using also batch_size: 100). When I start reindexing each product using find_in_batches method, it will reindex all products, but will not update settings and mappings. Is there any other way (maybe simpler) how can I only update settings and mappings of my index without reindexing the records itself (or anything else that would work and would not throw timeout error)? Here is the model configuration: |
Why is my RSpec not loading Devise::Test::ControllerHelpers? Posted: 17 Jul 2016 07:49 AM PDT I'm using Rails 5, and Devise 3.5.1. Going through a nice (older) book about creating/testing an API, which uses Devise authentication. It was written before Rails 5, so I chose not to use the new api-only version. Here's my test... And here's a completely unexpected RSpec error So I go here - http://www.rubydoc.info/gems/devise/Devise/Test/ControllerHelpers and tried this -> include Devise::Test::ControllerHelpers which didn't help because the file What did I miss here? Thanks |
Rails Devise token and cookie session at same time Posted: 17 Jul 2016 06:37 AM PDT I have a rails web which has been using cookie session authentication (devise) from its beginning. Now, we are developing an ionic mobile application which uses the API available from the rails application. I have considered to use JWT or token authentication for this new application but I can't find a way to combine both authentication methods, cookie and JWT. Also, both applications have different requirements. For example, in the web a user can have concurrent sessions only if he/she has a certain role. On the opposite, in the mobile application it is possible to have concurrent session without any restriction. I have reading a lot trying to figure how to combine both methods but I can't find the way. Maybe I should consider to use only one of the methods (JWT) or use another approach (doorkeeper). |
Rails simple_form with multi belongs_to association Posted: 17 Jul 2016 05:36 AM PDT In my app I have lots of model: (products belongs_to creator, creators belongs_to compagnie, compagnies belongs_to SEO, SEOs belongs_to user) in my first Seoscontroller I have that: (Controller work find!) In the Compagniescontroller I think (but not work:[ ) and in my simple_form.... I search a solution for associate my model id to the controller and the simple_form_for User model Seo model compagnie model form for Seo form for compagnie Thanks |
Posted: 17 Jul 2016 06:24 AM PDT In the following, what is the reason for having |
How can I use Twitter API with Ruby on Rails to retreive tweets from a users follower? Posted: 17 Jul 2016 04:54 AM PDT Beginner here so please be kind! So im trying to create my first twitter bot and have done the whole post to twitter etc thing, What i'd really like to do now is be able to use my RoR app to retrieve tweets from my followers and be able to search them for a keyword? Also whilst I have seen tutorials online on how to do this, is there a way to use BootStrap to make them more visually appealing? Hope you can help. Thanks |
Ruby on rails application with single http endpoint Posted: 17 Jul 2016 07:27 AM PDT Can someone explain what "app with single end point" means in term of rails? How do I set up this endpoint? |
'rails server' returns error with mysql 5.7.13 on osx elcapitan Posted: 17 Jul 2016 05:45 AM PDT I am new to ruby on rails and also to programming. I have followed instructions on the internet and setup rails application. It worked the first time but later when i reopen it and tried to run 'rails server' it doesn't work and returns following error. I would be happy if some one helps me out of this, i have been searching the internet for 5 hours. Thanks. I am using ruby 2.3.1p112 rails 5.0 mysql 5.7.13 $ rails server => Booting Puma => Rails 5.0.0 application starting in development on http://localhost:3000 => Run /Users/bruce/sea/config/routes.rb:6:in `': undefined method `root' for main:Object (NoMethodError) 5.0.0/lib/active_support/dependencies.rb:287:in `load' 5.0.0/lib/active_support/dependencies.rb:287:in `block in load' 5.0.0/lib/active_support/dependencies.rb:259:in `load_dependency' 5.0.0/lib/active_support/dependencies.rb:287:in `load' /rails/application/routes_reloader.rb:40:in `block in load_paths' /rails/application/routes_reloader.rb:40:in `each' /rails/application/routes_reloader.rb:40:in `load_paths' /rails/application/routes_reloader.rb:16:in `reload!' /rails/application/routes_reloader.rb:26:in `block in updater' 5.0.0/lib/active_support/file_update_checker.rb:77:in `execute' /rails/application/routes_reloader.rb:27:in `updater' /rails/application/routes_reloader.rb:7:in `execute_if_updated' /rails/application/finisher.rb:119:in `block in ' /rails/initializable.rb:30:in `instance_exec' /rails/initializable.rb:30:in `run' /rails/initializable.rb:55:in `block in run_initializers' /tsort.rb:228:in `block in tsort_each' /tsort.rb:350:in `block (2 levels) in each_strongly_connected_component' /tsort.rb:431:in `each_strongly_connected_component_from' /tsort.rb:349:in `block in each_strongly_connected_component' /tsort.rb:347:in `each' /tsort.rb:347:in `call' /tsort.rb:347:in `each_strongly_connected_component' /tsort.rb:226:in `tsort_each' /tsort.rb:205:in `tsort_each' /rails/initializable.rb:54:in `run_initializers' /rails/application.rb:352:in `initialize!' /rack/builder.rb:55:in `instance_eval' /rack/builder.rb:55:in `initialize' /rack/builder.rb:49:in `eval' /rack/builder.rb:49:in `new_from_string' /rack/builder.rb:40:in `parse_file' /rack/server.rb:318:in `build_app_and_options_from_config' /rack/server.rb:218:in `app' /rails/commands/server.rb:59:in `app' /rack/server.rb:353:in `wrapped_app' /rails/commands/server.rb:124:in `log_to_stdout' /rails/commands/server.rb:77:in `start' /rails/commands/commands_tasks.rb:90:in `block in server' /rails/commands/commands_tasks.rb:85:in `tap' /rails/commands/commands_tasks.rb:85:in `server' /rails/commands/commands_tasks.rb:49:in `run_command!' /rails/commands.rb:18:in `' /spring/client/rails.rb:28:in `load' /spring/client/rails.rb:28:in `call' /spring/client/command.rb:7:in `call' /spring/client.rb:30:in `run' /spring:49:in `' /spring/binstub.rb:11:in `load' from /Users/bruce/.rvm/gems/ruby-2.3.1@global/gems/spring-1.7.2/lib /spring/binstub.rb:11:in `' |
Execute JS every time on the event of turbolinks load in Rails 5 app Posted: 17 Jul 2016 05:15 AM PDT I would like to execute a few lines of js every time turbolinks is loaded(i.e, the page is loaded), not the js from cache, but would like to force run it before the event of turbolinks load, every time. Is that possible? I'm trying to get rid of FOUC here, by hiding the html body and doing this in app.js.coffee But the FOUC starts kicking in after the 3rd or 4th time of reloading the page. To see this live in action, here is a link to the website. |
Start MySQL when Rails server gets started? Posted: 17 Jul 2016 02:56 AM PDT When I start my Rails 4.2 app locally I ofter get this error: I then type Is there a way to start MySQL automatically every time the server gets started? I am on Mac OS 10.11.5. Thanks for any help. |
Ruby on Rails: Optimising multiple http requests to another server Posted: 17 Jul 2016 06:36 AM PDT My app makes http requests to another server on behalf of users. This question concerns doing this in the optimal way. The app may need to return the result of many http requests (to foreign server) to a user as quickly as possible. I have used threading to optimise this as best I can. However, I don't know enough to understand what happens when multiple users use the site at once. Bizarrely, when I simulated a few users making requests to the (local) development server at the same time, the response time didn't appear to suffer at all. I was thinking of making a class that queues http requests and processes them when it can, however, I wouldn't know whether to instantiate it at App level or User level. The local Web server is webrick and the production server is puma. Questions:
|
Posted: 17 Jul 2016 02:13 AM PDT I am trying to create a dashboard for my app. It is not a normal admin panel as I am trying to localize each dashboard to separate models. In other words, I have a model Shop. Each shop has_many Products. Each shop has its own Dashboard which allows a user who has a position at this shop to create and edit this shops products. I am struggling when it comes to designing the routes so that when an employee goes to site.com/shops/5/dashboard he enters his/hers shop dashboard and sees all action he/she is allowed to manage(add product, edit product, add employee, edit employee, etc.). Currently, the routes look like this: How to separate the :new, :edit, :destroy actions in a namespace so that later I can access all dashboard actions? Would the following be unreasonable for my situation? |
Ruby Rails - Where to start my understanding Posted: 17 Jul 2016 02:56 AM PDT I'm trying to learn code and currently running through the exercises within codecademy for Rails. Though I find this a good learning resource, i'm struggling to understand the relevance of the commands etc to "real life", so I can relate to it. Can anyone recommend "real life" projects to work through on line re. rails, so I can piece all the fundamental pieces together, whilst seeing what my actions do to the outcome project. Thank you in advance. Brendan |
Correctly filled fields should stay filled after error (Angular) Posted: 17 Jul 2016 01:26 AM PDT I have a problem with register fields in my app. This is my views new.html.slim When I fill others field wrong - correct field email_organization are empty, and when I delete line What I did wrong? |
How to develop new features for rails app without affecting existing website Posted: 17 Jul 2016 01:25 AM PDT I have recently launched version 1 of my web application and it is currently online and im getting a small amount of traffic on a daily basis. I now need to start developing new features for my application and also have the ability to test these features online on heroku without affecting the existing website until the feature is fully developed and ready to go live. How can I do this? Is it as simple as creating a new branch with git? Or is there a way to have a seperate url that only I can access in which I can push these new features and test them out before pushing it to my main site? |
Rails database migration fails with “duplicate column name: email” Posted: 17 Jul 2016 05:30 AM PDT I am fairly new to Rails and I'm currently installing the devise gem. When I created a User model and attempted to migrate the database: I get the following error response: I'm not exactly sure what a schema is for, but here is a copy of my schema. It's empty, and I thought it was suppose to be until the database is migrated: And here is a copy of my migration file in db/migrate: I'm fairly new to Rails, so I'm actually quite lost on what this error means. I'm assuming I apparently already have a column named: "email". Also, I commented out the t.string :email and typed the following: And I get a differnet error: |
Posted: 17 Jul 2016 06:22 AM PDT I've installed the rb-scpt gem in my Rails project and ran bundle. The gem is a fork from rb-appscript. The following program works when run from Terminal: I created a controller to do the same thing: When I run it, I get an error on line 3: What am I missing? I'm sure it's something simple. |
How to redirect in ruby on rails app from old sites url Posted: 17 Jul 2016 04:09 AM PDT I am updating my site from PHP to Ruby on Rails. How to redirect from old pages? example: old page: new page: |
Command to start rails server when using Puma + Nginx Posted: 16 Jul 2016 10:07 PM PDT I just pushed my Rails app to my remote server using Capistrano. The app is deployed under the I'm using puma as a web server and have nginx configured to look for a socket to which it should forward all incoming web traffic. Snippet from my nginx site config file - Correspondingly, my The last piece is to start my Rails app. What is the command that I should use to start it? I tried however this did not create a socket at the path mentioned above. I also confirmed it by trying to hit my URL and nginx threw up a 502 bad gateway. Should I be using Thanks! EDIT: When I search for the puma process that's running, it tells me it's listening on a TCP port. I'm not sure how that differs from sockets, but could that be the problem? |
How to call Rails ActiveModel.some_class_method from external thread without of connections broking? Posted: 16 Jul 2016 10:28 PM PDT I have a Rails (4.2.6) app and my extending class 'lib/messaging.rb': which communicates with the class Friend: I suggest that I am doing not in the best way, but Your help would help to understand the way)) The problem outstands in exceptions's messages:
I followed pt.3 from recommendations here http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/ConnectionPool.html#method-i-checkout and other publications that leaded me to understanding that if I use a query on an ActiveModel within a separate Thread then I have to close the connection within this thread. These lead me to using ActiveRecord::Base.connection_pool.with_connection(&block) method. And there is still something wrong( I suggest that I need to join Messaging and Friends somehow in Rails way, but I am confused if the only way is to make http requests(and then all the process will be under Rails controlled threads). I can't catch how to move this Messaging under Rails control. I have also and The code is abstracted but represents a real issue. In the real could occur thread-in-thread and sequential queries, but I use the #with_connection(&block) and completing queries with #to_a or #find within each of the &block. But something is wrong((.. Thanks more for any help!! I am really in stuck with this( |
Value not being persisted on form error Posted: 16 Jul 2016 09:27 PM PDT I have a form, that won't persist (or at least fill) the date input when the submission fails. For example, let's say I have a form that has two inputs, :date and :post. Both inputs are required. If I fill in :post, the form errors saying :date is require, but it persist and fills the :post value when it errors. Which is normal behavior. If I fill :date and leave :post blank, it errors again. However, this time it won't persist (or at least fill) the :date field when it re-renders the form. Clearly the :date is being passed through, so not a strong param issue. And I can manually fill in the :date field on error. Setting value for the :date input to params[:form][:date] works, but I shouldn't have to do that. The value is clearly in the params hash, it just isn't being fill when the form errors. Every other value on the form is being set, just not that :date value. It's not a huge issue, but it is driving me nuts. And as of right now, I'm out of ideas. Any help would be appreciated. |
Coffee script event not firing - why not? Posted: 16 Jul 2016 09:53 PM PDT I cannot seem to get a coffee script even firing. My code is below - and i hope it will help someone in future. Question: Why isn't the coffee script firing? what am i trying to do
Here is my coffeescript: And here is my form: Any idea where the problem is? Any assistance much appreicated. |
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