How to stub RSpec update action? | Fixed issues |
- How to stub RSpec update action?
- binding_of_caller -- Gem::Ext::BuildError: ERROR: Failed to build gem native extension
- Loading table into an array constant
- How do I move objects from one controller to another in Rails?
- Parse remote csv on Rails 4
- How to upload file in nested parameter using CURL
- How to set height of a row in xlsx sheet based on content?
- Using the one-liner syntax for controller specs
- ActionController::InvalidAuthenticityToken rails 5
- Limit number of Associations based on their value
- ruby JSON.pretty_generate() doesn't work
- paypal payouts resulted denied status
- Rails - how to correctly implement a payment/booking process
- ActiveAdmin: Not saving association between my two models
- Store uploaded images tdefinitely based on their json representation
- Partial Pivoting in PostgreSQL or Rails
- Images are not properly stored in temp folder in Apache where working fine in Rails production mode
- how to pause/resume of file during uploading on server in rails
- LoadError: cannot load such file — capistrano/rbenv (2)
- Ruby on Rails console --help not working
- Get set of hashes from array of hashes between two date values
- Quickbook Create invoice error in rails
- how to add rows dynamically in ruby on rails with jquery?
- Can't start my postgres server
- Issue in mobile device in the ajax call remote option
- Loop through array of hashes in rails
- Creating Filter Form in Views
- How to create a method in rails which executes automatically at a given time
- How to hit the api that runs on ubuntu inside virtualbox?
- Error session-1::#<Net::SSH::Connection::Session:0x2cfc238>
How to stub RSpec update action? Posted: 04 Oct 2016 07:45 AM PDT New to RSpec and having trouble stubbing out an update method (needs to be stubbed) and am running into this error. I have tried a bunch of different ways and can't seem to solve it. I tried to include only the necessary code.
When I run this test I get this error: So it looks like the and i get the failure: And now the names aren't matching |
binding_of_caller -- Gem::Ext::BuildError: ERROR: Failed to build gem native extension Posted: 04 Oct 2016 07:43 AM PDT I encounter this issue with ruby version ruby 1.9.3p551, OSX EI Capitan, when i am trying to run below command and the description of error as bellow: Building native extensions. This could take a while... ERROR: Error installing binding_of_caller: ERROR: Failed to build gem native extension. |
Loading table into an array constant Posted: 04 Oct 2016 07:32 AM PDT I have a Rails App that's essentially an invoicing and payment system. Within the application i have 2 tables that hold the misc_charges codes and description (ie: id:1 , code: '01' desc:'Apples' , id:2 , code :'02' , desc: 'Bananas' etc. ) the other table is the credits (ie: id:1 , code: '30' , desc: 'Coupon' , id:2 , code: '31' , desc: 'AAA rebate' etc). These codes are not subject to change very much and we are likely to add codes rather than modify or delete any of them. Currently, we store the alphanumeric code in the main transaction table. such as '01' , '02' , '30' or '31'. I could have used the id generated by rails/postgresql but the reason why we use the alpha codes is because this data will eventually need to be exported and imported into another system that uses those alphanumeric codes as the primary identifier for the misc charges and credits. Anyhow, currently in the app, when a user (or an admin) reviews their transaction history or a specific invoice, using the transaction table i get the specific description for an alphanumeric code using a model method. Then in the view i use this: Currently, the application is in development mode and we're doing some testing in a staging environment. We don't have a whole lot of transactions but i can't help but to think that calling the model to show the description for every code is bound to create some performance issues when the transaction count skyrockets or we have multiple users using the App at the same time. Is there a way to load those codes and descriptions, which will essentially be static most of the time, into an array as a constant? I have seen articles about Ruby on Rails constants that you can define in the application.rb or in the initializers folder but the example i have seen are mostly for static data... not something loaded from a table... Are the models available to pull data from in the application.rb or initializers? Can it be as simple as doing this or is there something more to it? Once i have that in an array, how do i go about replacing the Model method call in the view to snatch the proper description? |
How do I move objects from one controller to another in Rails? Posted: 04 Oct 2016 07:06 AM PDT What I building is a nifty booking system where I want to move objects say "Orders" when booked by user to "BookedController" I first implemented using sessions but it is limited to a session so I basically was thinking of an "Order" with the UserID who booked it and display it on that basis but I couldn't figure how. What I tried was sorting in categories, like New, Booked & Completed making them work like Flags but when user hits Booked, how do I change from New to Book and Associate with the UserID? So I thought of this way of creating a completely new controller and adding User_ID of person who hits book and showing the orders based on users but I don't think either of these are good ways to do it? |
Posted: 04 Oct 2016 06:50 AM PDT I keep getting the error file name is too long. I am running rails on Heroku so I am trying to have an uploaded file saved on cloud, and then imported so it is not lost on their dyno. I want to create a new object for each row in the csv. Parsing the CSV has worked perfectly before in development when using a temp file. But I have to change this for Heroku. What is wrong about my code for the remote csv being parsed correctly? |
How to upload file in nested parameter using CURL Posted: 04 Oct 2016 06:44 AM PDT I can upload single file using the following command. But I need to send multiple images in nested parameter. like
How should i form CURL command? |
How to set height of a row in xlsx sheet based on content? Posted: 04 Oct 2016 06:30 AM PDT I am using rails "acts_as_xlsx" gem for generating reports.I want to set the height of row automatically based on content. Here i am setting default height Here problem is the content in "description" field may vary.So,based on the content i want to set the height of a row.Is it possible? Thanks |
Using the one-liner syntax for controller specs Posted: 04 Oct 2016 07:00 AM PDT I'm trying to write terse tests for an API controller, but I'm having trouble with the "one-liner" syntax offered by RSpec. I'm overriding the subject explictly to refer to the action of posting rather than the controller: When I use the one-liner syntax to test http_status, it works fine: But when I try to use it for a different expectation, it blows up: Notably, when I run this second expectation in a longer form, calling on subject explictly, it works: Is this just a weakness of the one-liner syntax, that it can't handle this more complicated expression? Or have I misunderstood something about how subject is inferred into these tests? (NB: I know that setting the subject to an action has some detractors, and I'm happy to hear opinions, but that isn't the aim of this question). |
ActionController::InvalidAuthenticityToken rails 5 Posted: 04 Oct 2016 07:33 AM PDT I'm using rails version - I used I am using ajax to send the request to the server. This is the form that is displayed in the browser. It is a ajax request to the server when i view in the networks tab its showing |
Limit number of Associations based on their value Posted: 04 Oct 2016 07:23 AM PDT I'm fairly new to this, so apologies in advance if this is a dumb question, or if I should be approaching this in a different way. I'm certainly open to almost all suggestions! I'm working on creating a Jeopardy backend API using Rails 4. Currently, I've seeded my database with about 100 or so Categories, and each Category has multiple Clues, which house the question, answer and value. I also have a Game model which, when created, randomly selects up to 5 Categories and their clues. My issue is that I want to know if there is a way to make sure that each Game only has five clues, and no duplicating values (ie, I don't want 5 clues that are all worth $100). I'm not sure if this is possible to do on the backend or if I should just filter it out on the frontend (I'm not using any Views - I'm building a separate dedicated JS client that will use AJAX to get the data from the API), but I feel like there has to be a Rails way to do this! I'm not using any Join tables - Clues belongs_to Categories, and Categories has_many Clues, then a Game has_many Categories, so it's a pretty straight tree structure. I'm not sure what code would be helpful here for reference, since my Category and Clue models are pretty bare-bones at the moment, but here is what my Game model looks like: Any advice at all will be greatly appreciated!! Thank you in advance! |
ruby JSON.pretty_generate() doesn't work Posted: 04 Oct 2016 05:38 AM PDT I'm trying to print JSON data in a view in a 'pretty' human readable format. I have a controller: and a simple view: But all I see, when I load the page, is the same JSON I've got, not formatted. What do I do wrong? |
paypal payouts resulted denied status Posted: 04 Oct 2016 05:31 AM PDT I have created a US based paypal account and a block of code for paypal payouts but it resulted denied status. paypal accounts email is confirmed but the senders sandbox account seems to unverified and could not find any way there to confirm it. Could anyone help me on this. Regards, Sreeraj |
Rails - how to correctly implement a payment/booking process Posted: 04 Oct 2016 07:26 AM PDT I'm building an events app in rails and I'm using Stripe to collect my payments. It took me a while but I've got payments working. However, when I try and increase the quantity of spaces to book, the system will only take one payment. So if an event is £10 per 'space' and someone wants to book 5 spaces, regardless of the fact the payments form states the correct amount (£50 in this example), only £10 is collected. I'm pretty sure this is an MVC issue but can't seem to spot how to resolve it. In my views I have the following code - bookings.new.html.erb This works fine on the actual payments page as the example below shows - So, for this example I've used an @event.price of £1 per space/booking. However, if I go ahead and process this booking, rather than £3 that is collected by Stripe, it only shows as £1. I think this may have to do with the fact @event.price is what I'm expressing in my views, however,when I replace @event.price with @booking.total_amount I then only get the total amount in my payment form (as above) showing as zero and regardless of what I do with the quantity function it stays at zero. As you can see from the views code my quantity function is handled with some javascript. Am I missing something from this function to make this work? Do I have the correct params in my controller? Here's my controller code - bookings_controller.rb Here's my model code with validations - Booking.rb This has had me stumped for a while. I'm pretty new to Rails so feel sure a more experienced eye can spot where I'm going wrong. Any guidance is appreciated. |
ActiveAdmin: Not saving association between my two models Posted: 04 Oct 2016 04:53 AM PDT How can the association between my two models be saved in ActiveAdmin?I have two models a room and a photo model. In the ActiveAdmin I want to update the association between the photo and the room. room.rb (app/models) photo.rb (app/models) photo.rb (app/admin) The form seems to work but it does not save it to the database when I check the record(last room) in the rails console it always returns me room_id: nil? I have tried everything nothing seems to work. Please help. |
Store uploaded images tdefinitely based on their json representation Posted: 04 Oct 2016 04:45 AM PDT Hello everyone since the past hour i've been trying to use minimagick gem, but i can't figure out why i can't open an image. the return value is always null i have the following code in my controller: On a get to upload#load i get a null value. i have installed minimagick on my mac using homebrew. i restarted the server. Thanks! |
Partial Pivoting in PostgreSQL or Rails Posted: 04 Oct 2016 04:42 AM PDT Assume I have 3 tables, and I can't change any DDL and and Also, assume that the string enum will always correct, filled by only one of those three possible values. And I need a resulting query like this I know that I can handle it in Rails How can I generate that needed output with using only one query? |
Images are not properly stored in temp folder in Apache where working fine in Rails production mode Posted: 04 Oct 2016 03:58 AM PDT I am using IMGKit for generating screenshots. According to the code, I am taking a screenshot of a particular page / url as mentioned and then storing this in a path. When I upload new image, the image is overriden with same filename which is right. This is working fine in RAILS_ENV=production but when I try to run this in Apache, it is showing the same image all the time irrespective of the url. Please help. |
how to pause/resume of file during uploading on server in rails Posted: 04 Oct 2016 03:58 AM PDT i want to make a resume able video up loader in rails . what is the best way to make this .should i use to fineuploadr , or jquery-file-uploader. is it possibale with paperclip gem ruby or not ? I tried it with jquery file uploader plugin . here is my _form. end |
LoadError: cannot load such file — capistrano/rbenv (2) Posted: 04 Oct 2016 03:52 AM PDT This is almost the same question as here: LoadError: cannot load such file -- capistrano/rbenv I experience the same problem as described there but neither solution does work. I thoroughly followed the instruction at https://gorails.com/deploy/ubuntu/16.04 - but it did not work. My question is: if I want to set up rbenv on a remote computer - do I have to have rbenv on my local computer - where I run I currently have RVM on my local computer - but want to set up rbenv on a remote one. Perhaps it's not possible and I must firstly replace RVM on the local computer to rbenv? |
Ruby on Rails console --help not working Posted: 04 Oct 2016 03:44 AM PDT I have rails 5 installed via rvm, and when I type rails -h or rails generate model -h etc, I only get the standard help message : I should be able to get help with all of the different rails commands on the console. Any suggestions? Thanks. |
Get set of hashes from array of hashes between two date values Posted: 04 Oct 2016 03:49 AM PDT I have an array of hashes that contains a date and total key. For example: What I want to do is pass two dates to a method that then returns only hashes whose dates are either matching or between the two dates. So for example: Where the startDate and endDate are '02/01/206' and Would return: |
Quickbook Create invoice error in rails Posted: 04 Oct 2016 07:07 AM PDT i am getting this error when i am creating invoice using Quickbook rails gem (quickbooks-ruby) My Controller config/initializers/quickeebooks.rb |
how to add rows dynamically in ruby on rails with jquery? Posted: 04 Oct 2016 03:44 AM PDT Application contains invoice line item. While creating new invoice, I need to add rows dynamically in table contains information regarding product name, description, and product unit cost. I have a "Add" button, when user press this button one row will be added in the form. Code from new.html.erb in which i have created table body. now I need solution to add rows dynamically via jquery. So for that I tried following code. but failed to generate output...invoice_item.js is as follows if I wanted to append the new.html.erb code to the page using jquery, what is the best way? |
Can't start my postgres server Posted: 04 Oct 2016 03:11 AM PDT When I try to launch my psql server, I receive a postgres popup saying:
To give a little bit of a context, I've killed all my postgres connection with the following command: as I wasn't able to rake db:reset my db. Problem is that now that I can't use postgres on any of my apps. |
Issue in mobile device in the ajax call remote option Posted: 04 Oct 2016 03:00 AM PDT In rails, I am using the same code to get js response and render UI according to the response . My code is like this But in the computer browser, it is generating js response while in mobile browser is generating html response In computer it is getting the server log While browsing in mobile it produces the log I want js reponse in mobile devise as well. What may be the issue? Please help me to solve . Thanks in advance |
Loop through array of hashes in rails Posted: 04 Oct 2016 03:07 AM PDT I have the following array of hashes that I send to my controller: And then in the controller I want to loop through these comparisons: I get an error: And when debugging I'm finding that the
How can I fix this? |
Posted: 04 Oct 2016 05:52 AM PDT So i am trying to filter the data that is presented in my Index action by using scope. I have defined it as so in It works perfectly fine in rails console, i can do What i would like to know is how do i create this input filter method in my index views? In I've tried collecting the information in my index view in various ways, all to know avail. Any help or advice would be greatly appreciated. Thanks! |
How to create a method in rails which executes automatically at a given time Posted: 04 Oct 2016 02:31 AM PDT I want to create a method which contains email function.But i need to run a scheduler at 12:00am daily.Which should check from employee table whether there are any Birthday of any specific employee related to that specific date.If it founds an Birthday then it should send an greeting to the employee using rails Action Mailer.It is possible if i take button and when i click on it then email should be gone,but i want this automatically without any onclick event.So pls help by providing an Example for this. |
How to hit the api that runs on ubuntu inside virtualbox? Posted: 04 Oct 2016 02:36 AM PDT i'm facing difficulties to hit the api runs on ubuntu inside virtualbox. virtualbox's ip address is 10.0.2.15 . when im trying to hit this ip, i cant access it. so help me to hit the rails api, that runs on port 3000 TIA |
Error session-1::#<Net::SSH::Connection::Session:0x2cfc238> Posted: 04 Oct 2016 04:17 AM PDT While i was running one of my ruby script it is throwing error like "session-1::#".And it is continuoesly in the loop only. |
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