How do I get RSpec and Cucumber tests to run in an app using both Mongoid and ActiveRecord? | Fixed issues |
- How do I get RSpec and Cucumber tests to run in an app using both Mongoid and ActiveRecord?
- Unexplicable InvalidURIError after controller testing
- What i wrong with my html.erb file?
- Database configuration errors while deploying Rails app to Heroku
- How can i call model method in Rails 5 with ajax?
- When is touch_record (belongs_to.rb) called?
- Sass::Engine.new Rails | Compiled css file has code from the scss.erb template file causing the css file to have errors
- How to make this link to send PUT request.?
- Using Cassandra in Rails App
- Rails factory_girls and validation issue
- /Users/user/.rvm/rubies/default/bin/ruby: No such file or directory -- script/rails (LoadError)
- Production error env
- Rails navbar conditional and getting No route matches in root_path
- Rails: how to check CSS or JS code code from a string?
- FriendlyID for child
- getting error, Mysql2::Error: You have an error in your SQL syntax in rails?
- Rails, how to use a block in where statement
- Adding a scope to ruby gem validation of uniqueness
- Two levels of nested attributes and strong parameters
- Error: Postgres database import in docker container
- How to password protect Munin directory?
- How obtain connect with OAuth 2 using Postman?
- How to merge multiple docx files into one docx file in rails?
- Create Wistia model in Ruby on Rails
- Rails: Accessing image files after being uploaded
- Rails 4 after_commit nested conditions issue
- Active Admin Installation Error
- what configuration do i need for actionmailer to work in cloud9?
- How to use "has_many through" model in form of active admin
- How to save attachment locally using trix editor
How do I get RSpec and Cucumber tests to run in an app using both Mongoid and ActiveRecord? Posted: 30 Dec 2016 07:25 AM PST My team's project is a Rails 4.2 app using Mongoid 4. A new feature we are adding requires us to read data from a Postgres DB and use those records in the app through an intermediary object. In other words, our app will play with ActiveModel objects (non-persisted) that contain a mix of data from Mongoid models and ActiveRecord models, and thus can do all the normal cool Rails stuff with Controllers and Views, etc. (We think it's clever.) The intention right now is that we will never write to the SQL tables, just read. Any new data stored will be in mongodb. For my development environment, the first steps seemed pretty straight-forward:
Using the rails console, I was able to prove to myself that I could search/find objects in both databases. So far so good. When I first fired up the rspec tests, there were tons of failures related to validation errors because "records already existed with that name". Long investigation story short, I fixed by setting all DatabaseCleaner calls to be BUT, Cucumber (feature) tests? I can't even get them started. It keeps saying: No! All those migrations we have are for MONGO. There are no SQL/ActiveRecord migrations. Not surprisingly, that rake fails: I tried this series of commands: but cucumber still gives the same migration pending error. So I'm stuck! I haven't found anyone doing what we're trying to do. I know there HAS to be someone, I just haven't found the right search terms, apparently. The worst part of all this is I had no intention of even using an ActiveRecord test database at all, I was simply going to mock those records in my tests. How can I tell the app, "I only need ActiveRecord for runtime, not testing. Stop looking at the migrations, ActiveRecord, those aren't for you!" I have run out of ideas and words to search with. I've been trying to solve this problem for a couple of days now and have tried SO many different things, please forgive me if I've left some of those out here. Any assistance would be greatly appreciated. |
Unexplicable InvalidURIError after controller testing Posted: 30 Dec 2016 07:03 AM PST I was testing my Rails 5.0 application with the following code: but the test kept failing: So, in order for the test to pass, I had to change my code using instead the following code: I have no idea why I could not make the test pass calling |
What i wrong with my html.erb file? Posted: 30 Dec 2016 07:08 AM PST from the code below, I get the following error: /home/ubuntu/workspace/portfolio/app/views/projects/_project_form.html.erb:36: syntax error, unexpected keyword_ensure, expecting end-of-input because it is a syntax error, I am guessing I wont need to provide other details but if you guys need me to post more feel free to ask. |
Database configuration errors while deploying Rails app to Heroku Posted: 30 Dec 2016 06:55 AM PST I'm using Rails 4.2.3 I received the classic "sqlite not supported" error initially, and then removed all references to Now I'm getting: My database.yml looks like this: I've also tried: |
How can i call model method in Rails 5 with ajax? Posted: 30 Dec 2016 06:53 AM PST I've a Task model in Rails with this method that returns the number of particular tasks. I need to call it via Ajax, how can i do it? I know that i could use it in a controller method and call Ajax to controller (i know how to do this) but then the controller method would be attainable via url. |
When is touch_record (belongs_to.rb) called? Posted: 30 Dec 2016 07:38 AM PST In this method from belongs_to.rb, def self.touch_record(o, foreign_key, name, touch) I am trying to get the 'o' class. I try : bundle show activerecord then open 'thepathgivenbymyfirstcommand' and put a 'binding.pry' in the method Finally, I moved into a rails project (with belongs_to association already created) and try to update/destroy as they said here :":touch If true, the associated object will be touched (the updated_at/on attributes set to now) when this record is either saved or destroyed. If you specify a symbol, that attribute will be updated with the current time in addition to the updated_at/on attribute." but nothing happened, I never stop at the "binding.pry" to get the 'o' variable class. Do you have any advice ? |
Posted: 30 Dec 2016 06:31 AM PST I have made use of the Sass engine in rails to produce a custom css file for each element a user can add to the site. This is my generate css code The template file it uses is just a list of variables and a sass if statement to check which mix-in to use. This when compiled seems to keep around 22 lines of code from the template file. This isn't a major problem as the css file still renders in the browser fine but it is annoying knowing I have incorrect/ erroneous files. Any ideas on how to trim/remove reformat the final compiled css? |
How to make this link to send PUT request.? Posted: 30 Dec 2016 06:33 AM PST This is a helper method to generate a link in the_comments gem. I want to make it put request. If any one know how to make it PUT request please help me. |
Posted: 30 Dec 2016 05:42 AM PST I have a couple of questions about working with Ruby on Rails and Cassandra. I have a PostgreSQL database and a Cassandra database separate from my Rails application. I would like to access Cassandra to make some queries through my Rails application. What is the recommended way of Cassandra integration into a Rails app ? Is there any reference implementation? Regards, |
Rails factory_girls and validation issue Posted: 30 Dec 2016 06:07 AM PST I have HABTM association my models my factories My problem is when i want to create i have got Why it happens? |
/Users/user/.rvm/rubies/default/bin/ruby: No such file or directory -- script/rails (LoadError) Posted: 30 Dec 2016 05:32 AM PST I want to use Ruby with Netbeans IDE. But I get error when I start Ruby on Rails project in console: But there is a file: Do you know how I can solve this issue? |
Posted: 30 Dec 2016 06:57 AM PST In development mode the rails normally run, but not in production. I already ran rake db: migrate file production.log |
Rails navbar conditional and getting No route matches in root_path Posted: 30 Dec 2016 05:46 AM PST Hello I want to show the search form inside the navbar only in the index page of products and the show page of the product. The thing is that it is showing on both the index page and the show page but when I click home to go to the root_path I get the following error: No route matches {:action=>"show", :controller=>"products"} missing required keys: [:id] How can I avoid that? This is my code in the application.html.erb: |
Rails: how to check CSS or JS code code from a string? Posted: 30 Dec 2016 05:34 AM PST In a I need to check if the syntax is correct. Currently I found a ugly hack which works. Do you know a better solution? |
Posted: 30 Dec 2016 05:32 AM PST I have a Project model that belongs to a User. A User has_many Projects. I have setup FriendlyID according to the gem instructions for User model, however it is not working in this scenario. The above creates a link with the numerical ID of the user (project.user) instead of a friendly URL (i.e. http://localhost:3000/users/102 instead of what I want, http://localhost:3000/users/*random-gen-string*).
I think the problem is that Relevant code in projects_controller: What is the best way to go about making the above link link to the Friendly ID and not the user (i.e. http://localhost:3000/users/*random-gen-string* is what I want instead of http://localhost:3000/users/102)? |
getting error, Mysql2::Error: You have an error in your SQL syntax in rails? Posted: 30 Dec 2016 04:44 AM PST What needs to be changed in the below queries?. i want all those employees whose date_of_leaving is null or the date_of_leaving is in between the past 60 days or the date_of_leaving is greater than or equal to the Date.today or current date. i tried in another way also like below. |
Rails, how to use a block in where statement Posted: 30 Dec 2016 06:33 AM PST Taken from this stackoverflow-question, one can use a block for a query, like this: I want to do the same with a "where" query, for example: When I do this, I get something like this: I can't use ActiveRecord methods, for example: or What is the correct way for using blocks in a where statement? |
Adding a scope to ruby gem validation of uniqueness Posted: 30 Dec 2016 04:32 AM PST acts-as-taggable-on gem has a built-in uniqueness validation: How do I add a scope to this validation? I want to add |
Two levels of nested attributes and strong parameters Posted: 30 Dec 2016 03:21 AM PST I've ported a Rails app from Rails 3 to Rails 4 and most things work now, except for a problem with two levels of nested attributes:
I have a controller that updates ProductGroups. When the ProductGroup is updated, the master variant is updated at the same time. And prices in the master variant are also updated. Here's a test that describes what's expected to happend: But it fails with this error: As you can see in the debug output, there is a price with ID 510149407 for that variant. And why is the ID of the variant empty? I'm totally stuck. Here's the permits for ProductGroup that I'm using: Here's how ProductGroup relates to the master variant: Here's how Variant relates to Prices: I will gladly post any other excerpts from the code if it is of any help, but I'm not sure what could be of interest right now. Any hints would be much appreciated! |
Error: Postgres database import in docker container Posted: 30 Dec 2016 05:49 AM PST I'm running a ruby on rails application in docker container. I want to create and then restore the database dump in postgres container. But I'm Below is what I've done so far: 1) Added bash script in
RESULT: Database created but rails server exited with code 0. Error: 2) Added script to be executed before RESULT: Database created and restored data. But another container runs while running web application server using
Can some one please help to create and import database? EDIT: I've tried one more approach by adding I'm confused why I'm getting this error (in first and third approach), seems to be something is messed up in |
How to password protect Munin directory? Posted: 30 Dec 2016 03:19 AM PST I followed Munin, apache and how to password protect munin and have added .htaccess file in /var/www/munin with this code I have also generated .htpasswd file with apache utils has it has the username and md5 password. Now after reloading and restarting apache, I can still see example.com/munin content. I am running rails on example.com but I don't think that has anything to do with munin which resides on different path. Can you suggest me what I am missing out or if there is any other way using which I can password protect munin content ? |
How obtain connect with OAuth 2 using Postman? Posted: 30 Dec 2016 03:22 AM PST My API uses the devise_token_auth (omniauth) gem for authentication in the Rails 5 backend. The frontend are using ng-token-auth (Angular 1.x). I have all the API requests in Postman. I did the security implementation and I need authenticate Postman with every request. Devise_token_auth uses authentication with OAuth 2 and I am having difficulty to implementing this authentication. For this type of authentication, using Postman, what is the process needed to obtain the connection? |
How to merge multiple docx files into one docx file in rails? Posted: 30 Dec 2016 03:09 AM PST I have multiple docx files with same header and footer and want to merge them together to form one document keeping the header and footer intact. |
Create Wistia model in Ruby on Rails Posted: 30 Dec 2016 03:40 AM PST I am building currently an web app where the admin will be able to post a title with a description and a link / embedded form of Wistia Video Player. Currently my setup is:
How do i create a model for this? Normally i would create a model like this: But how do i implement the Wistia Video Player, so that everytime the Admin creates a new post, he will be able to link/embedded a new video? |
Rails: Accessing image files after being uploaded Posted: 30 Dec 2016 02:56 AM PST I am writing a Ruby on Rails 5 app. I just learned how to upload an image without using paperclip,carrierwave, or refile. I have used refile in the past but for this app, I wanted to learn how to do it with out those third party gems. And it was not that difficult to do. I have successfully uploaded a file. My problem is accessing the image afterwards! I thought this would be rather simple. But NO! I have image files being uploaded to "/public/images/page/image.jpg" I have added "/public/images/page" to the assets path in app/initializers/assets.rb I have tried straight img tag like this: I get a "(No route matches [GET] "/public/images/page/mars01.jpg")" error. I have tried: basically the same as tag, get same results. Also tried: still get routing error, but only looking in "/images" directory. I am still in development mode, so I thought that image_path would be the correct path. What is the correct way of accessing an image, that was just uploaded to a directory outside of the asset pipeline? That will work in development or production env? I really thought this would be straight forward. |
Rails 4 after_commit nested conditions issue Posted: 30 Dec 2016 04:34 AM PST I would like to trigger the same function for For now, my only solution was to duplicate the function and make two different Of course it works but it doesn't make the code DRY at all. I'm sure there is a better solution but I haven't found any relevant examples on the official rails doc What I'd like is something like this: But there is an error with twice the declaration of |
Active Admin Installation Error Posted: 30 Dec 2016 04:41 AM PST I created a sample application in RubyonRails and tried to use Active Admin gem. Added the below lines to Gem file: Then ran the following command |
what configuration do i need for actionmailer to work in cloud9? Posted: 30 Dec 2016 02:25 AM PST I have been following this simple tutorial for sending mail using ActionMailer. http://guides.rubyonrails.org/action_mailer_basics.html The configuration i am using in development.rb file is as follows: I have also tested with gmail smtp but with no success. The above configuration is for mailgun smtp. I send email through the terminal and the following message is printed in console. But the email is never received by the recipient. I am doubtful whether i have missed an important configuration for cloud 9 that is not letting me send emails. I appreciate any help! Thanks! |
How to use "has_many through" model in form of active admin Posted: 30 Dec 2016 02:02 AM PST So i have model "ClientHotel", "ConferenceRoom", "Slot" and associations between these is like and this is my file in app/admin/client_hotel.rb here how to add the slots attributes so that while creating the hotel i should be able to create the conf_room and slot also in one go. suppose i have check-in time & checkout time in slots table so how would i write that in above form |
How to save attachment locally using trix editor Posted: 30 Dec 2016 01:17 AM PST In ruby on rails, how to save attachment to folder using basecamp's trix html editor I got this error: POST http://localhost:3000/img 404 (Not Found) |
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