Double render error with rails Json API | Fixed issues |
- Double render error with rails Json API
- Using first_or_create in Sidekiq Job
- Not able to call a controller action in Rspec
- Capybara Rspec Rails get ID for path
- How to handle large JSON data when exploring an API?
- how to custom respond json in activeadmin gem rails
- How to log in to a remote rails application using devise, omniauth
- Get the current url and send ti via email on rails
- devise_token_auth for frontend and devise for backend - Why is it taking so long to sign in?
- Rails 4: Separate model and controller functions with validations
- Rails Spree 3.0.5 create promotion outside admin panel
- How do I Connect One Table To Multiple Tables?
- Paid membership Stripe Ruby
- Deploying Rails app with Apache, Passenger, Faye server, Private_pub
- Failure/Error: ReferenceError: Can't find variable on upgrade of teaspoon-jasmine 2.3.4
- Other information required if radio button selected, using Rails and Jquery validate
- How to add multiple callbacks to rolify gem
- Conditional Route on sign_out using Devise with Rails
- How to save image from url to local ubuntu folder from rails console?
- Rails/JS Modal popup insert value in query
- Ruby on Rails : Storing the pluck result
- Include all ids in ActiveRecord query
- Stripe do not save card detail in test server only
- After commit callback for a particular ActiveRecord transaction
- User saving his list before submit in ruby on rails
- How much traffic can a app on a Heroku free tier handle?
- PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer
- Sending object as a variable to Mandrill via Rails
- getting weird error in rails console
- Rails 4 unpermitted params error
Double render error with rails Json API Posted: 06 May 2016 06:57 AM PDT I have a controller action in my API that looks like this : the action is calling the methods set_office_access and save_user_and_send_invitation_email : However when I have a validation error for example when I try to save the user in AbstractController::DoubleRenderError - Render and/or redirect were called multiple times in this action. Please note that you may only call render OR redirect, and at most once per action. Also note that neither redirect nor render terminate execution of the action, so if you want to exit an action after redirecting, you need to do something like "redirect_to(...) and return". I tried adding How can I fix this ? |
Using first_or_create in Sidekiq Job Posted: 06 May 2016 06:52 AM PDT I have a Sidekiq Job with first_or_create. But this causes uniqueness validation to fail due to duplicate analysis records being created. I understand this is because first_or_create is not atomic. So what is the right way of doing this? |
Not able to call a controller action in Rspec Posted: 06 May 2016 06:52 AM PDT I have been trying to implement an RSpec for a Controller called "Estimate controller" to test whether my mailing functionality (sending estimate) working properly or not. But I'm not able to call the controller action from my RSpec. I need to set some values (to, subject, message, cc, current_user, attachments) in a hash and send that hash to Estimate controller.Here is what I tried.. estimates_controller_spec.rb estimates_controller.rb |
Capybara Rspec Rails get ID for path Posted: 06 May 2016 07:02 AM PDT Using capybara/rspec to test rails. Want to check current path is generated correctly with the id but cant access the created Contact id. Example expectation: localhost:3000/contacts/27 Example recieved: localhost:3000/contacts/ Code base: Surprised the interpolation hasn't worked and throws error undefined method 'id' for NilClass using the below. Clearly it cant access the id. Also tried swapping it out with Any ideas/thoughts? |
How to handle large JSON data when exploring an API? Posted: 06 May 2016 06:46 AM PDT Often I find myself in the situation where I start exploring a new API and get back large JSON objects. And everytime I struggle to find a way to display them properly indented, so that I can easily see the structure and identify the parts relevant to my task. Right now I am exploring the Z-Wave API for Razberry (Home Automation). I get back a JSON holding all the devices connected to the Home Automation network. It looks like this: And I don't understand why Rails breaks the lines in the way it can be seen here, and why it doesn't manage to indent the JSON data properly. The output on the screenshot is the result of this controller code: It would be interesting to see how more experienced programmers handle JSON at this stage, when exploring the datastructure. How can I display the JSON in this style?: |
how to custom respond json in activeadmin gem rails Posted: 06 May 2016 06:27 AM PDT I have a model Product. when i get respond @product type json but i want to show nested attributes in product same like: how to custom it? |
How to log in to a remote rails application using devise, omniauth Posted: 06 May 2016 06:27 AM PDT I have two applications, AppA and AppB, they are both Rails applications. I have created a single sign-on mechanism using Devise, Omniauth and Doorkeeper. This is where if you are logged into AppA, then you will be authorised to AppB, since AppB makes a oauth call to AppA to check this. AppA has devise and currently you have to login there. What I would like to be able to do is to create an ajax login form in AppB, and this would pass my credentials to Devise in AppA and give me access to AppB, instead of redirecting to appA and back. I seem to be able to do this OK if I disable CSRF checking in AppA, but I would like to be able to have an alternative where I either don't have to do this, or I can provide an alternative without any security holes. So my main question is if anyone has any idea how to do this, or if they have done something similar and have suggestions? Many Thanks, Eamon |
Get the current url and send ti via email on rails Posted: 06 May 2016 06:28 AM PDT I am new to Ruby on Rails. I am building a system that will enable users to create "ticket(s)" this means to report a problem about the applications that a company has built, basically, my system is an email management system where I will track the "tickets" by a ticket-id, when the user creates a ticket he/she will have to provide an email-address where he will be contacted back(via comment). So after the ticket has been sent(created by non-logged in user), I will comment back on that ticket, and so I am trying to get the absolute current URL and send it on email when I click a button to submit the comment, so the user who receives the email can click the link and will be redirected to the "show" view of this ticket. Besides this, how is it possible to make sure via a token that only the user who provided the email when he created the ticket, will have access to the link that has been sent on his email. Let me summarise: so far, I have the And so far I know that: And my routes: Thank you in advance. Best. Ibrax |
devise_token_auth for frontend and devise for backend - Why is it taking so long to sign in? Posted: 06 May 2016 06:16 AM PDT It seems like it is working correctly except, it will chug at the |
Rails 4: Separate model and controller functions with validations Posted: 06 May 2016 06:12 AM PDT I am trying to separate some logic from my controller but cannot get it working the way I'd like. I have a function in my controller that takes a CSV file and enters each row into my Then I have the CSV parsing function in my model but before creating the entry in the WeighIns table, I want to ensure there is a corresponding User for an attribute in the hash, i.e. How can I validate this and return a useful error that tells me there is "No User for scale_id: Foo" |
Rails Spree 3.0.5 create promotion outside admin panel Posted: 06 May 2016 06:09 AM PDT I want to send email for user, who buy a product, with a unique coupon to the next order. I know how can i create For example: User buy a T-shirt in my store. Then he(she) paid for it, I need to generate a new coupon with fixed discount(e.g. 5$) and send email to the user with this coupon. Firstly, I need to create a new promotion with some How can I do last step? |
How do I Connect One Table To Multiple Tables? Posted: 06 May 2016 06:05 AM PDT We have many existing tables right now in our database. For easier understanding lets say we have tables with these names: Each of these What I want to do is create The thing that is tripping me up is how to tie all of these together. Each user should only have one of each track, and each track should have access to all data inside of the track. The only thing I can think to do is something like: But this seems extremely sloppy and I'm not even sure if it will work. If you need more information or don't understand, let me know and I can try to word it better or describe in more detail. |
Posted: 06 May 2016 06:21 AM PDT I've been dealing with some errors ive been getting and lately somehow i made it happend but there's a thing i need to add a metadata to my code but dont know where too and how I need your help. Paid member is being registered but he's not being charge because its being registered without plan. I guess this is what I need to add :metadata[plan_id]=2 |
Deploying Rails app with Apache, Passenger, Faye server, Private_pub Posted: 06 May 2016 05:55 AM PDT I'm trying to deploy a Rails app on a RHEL server (CentOS 6) using Apache and Passenger. The app has a chat feature that uses private_pub. Currently the app is running on port 80 and the Faye server (for private_pub) is running on 8080. The app seems to be sending information to the Faye server. However, it does not seem to be getting any information back. If you navigate to 8080 directly, you get the correct Faye response. It looks like Faye is running correctly but something is up with the configuration, blocking the Rails app from processing a response. Any tips? |
Failure/Error: ReferenceError: Can't find variable on upgrade of teaspoon-jasmine 2.3.4 Posted: 06 May 2016 05:40 AM PDT Upgraded teaspoon-jasmine to 2.3.4 and jasmine to 2.4.0. All tests are failing it may be because of some configuration that i missed. Error it throws is : Failure/Error: ReferenceError: Can't find variable $.. Any suggestions on how it can be fixed? |
Other information required if radio button selected, using Rails and Jquery validate Posted: 06 May 2016 05:33 AM PDT I'm using the rails simple form gem and validating my form using the jquery validation plugin. I want to require "other information" when a radio button is selected as "yes" (or true). The rest of the validations I have are working fine but when I try to require text in an "other information", It's not being required. Here's my js And the part in question I've based my code on the dependency-expression found here https://jqueryvalidation.org/required-method#dependency-expression. I'm just learning rails so appreciate any help thanks! |
How to add multiple callbacks to rolify gem Posted: 06 May 2016 05:43 AM PDT According to rolify gem documentation. This gem adds the rolify method to your User class. You can also specify optional callbacks on the User class for when roles are added or removed: The rolify method accepts the following callback options: Mongoid callbacks are also supported and works the same way. when i add multiple callbacks to rolify it only works for last one my code only before_remove_method method called. Any suggestion how we can add multiple callbacks to rolify gem? |
Conditional Route on sign_out using Devise with Rails Posted: 06 May 2016 06:54 AM PDT I am working on an app in which there is a model User with roles member and Admin. As per requirement, I have to made two separate login pages for Admin and Member. with it goes to admin login page and with
it goes to member login page. Just after login I route them according to their roles to Admin panel or simple website for members. But at time of logout both goes to but I want admin to go to Is there a way to see User's Role at time of Sign_out and route them accordingly. |
How to save image from url to local ubuntu folder from rails console? Posted: 06 May 2016 06:02 AM PDT I need to write image parser from some website which will take images, some other info and save it to my local folder. So let's say we have image at this url : https://i.stack.imgur.com/MiqEv.jpg (this is someone's SO avatar) So I want to to save it to local folder. Let's say to And I tried this in my terminal: As you can see my home/test folder is empty And I got this output from console What do I do? Also I tried this: And got this output:
But my folder is still empty. What do I do?? |
Rails/JS Modal popup insert value in query Posted: 06 May 2016 05:18 AM PDT In a bootstrap Modal I want to give a value to Rails. CoffeeScript: That works. 12345 is shown. Now I want to pass that value which replaces the How to do that? Better ways to solve that? Thanks for help. |
Ruby on Rails : Storing the pluck result Posted: 06 May 2016 05:59 AM PDT Im creating a library management system as part of a college assignment. Im currently stuck on obtaining the result of pluck. The task Im trying to do here is to display a list of books that are currently in the table. Ive been primarily a PHP programmer so ruby on rails is a whole new world for me. From doing external research I found out about object.pluck. My knowledge of the above snippet is that Im pulling from all book objects there details. What I want to do is have a loop that will output each book followed by an edit button. In PHP this would be a form inside of a for loop. but with ruby I dont really know how to do it In my head I want to store the result of the pluck in an array of books[]. Then use a loop to iterate through that loop and output details of the book stored at index i. But Im not sure how to store the result of pluck? |
Include all ids in ActiveRecord query Posted: 06 May 2016 05:25 AM PDT I am developing a gaming platform and I have the following (simplified) models: I need to perform an ActiveRecord query that looks for all games played by a certain group of users. For example, given the data: I need to find a way to determine which games are played by the players with ids 39 and 41 which, in this case, would be the games with ids 10 and 13. The query I have found up to now is: However, this query is returning the games played by any of these players, instead of the games played by both of them. |
Stripe do not save card detail in test server only Posted: 06 May 2016 05:32 AM PDT The card is being add in development server but while running test server and adding card detail for cucumber test it doesn't save the card and shows the following error. ERROR Stripe::InvalidRequestError: Invalid token id: tok_18879VHs1bT44hDtvyLbWjOk |
After commit callback for a particular ActiveRecord transaction Posted: 06 May 2016 04:41 AM PDT I have an ActiveRecord::Base transaction: and I want to trigger an |
User saving his list before submit in ruby on rails Posted: 06 May 2016 06:06 AM PDT Hi i want to give two options for the user for his listing as, 1. Save 2. save and publish How could i do this in ruby on rails |
How much traffic can a app on a Heroku free tier handle? Posted: 06 May 2016 04:53 AM PDT I want to know how many concurent number of users at a time can use app deploy on free tier of heroku? Note : App server is by default |
PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer Posted: 06 May 2016 04:27 AM PDT I am doing a "IN" query using prepared statements on rails. I am getting PG::InvalidTextRepresentation error. code : trying to invoke this using : Please help here. I want to know why I am getting this errors and how to fix it. Thanks, |
Sending object as a variable to Mandrill via Rails Posted: 06 May 2016 06:20 AM PDT I'm converting an email template from Rails to Mandrill, the content for which requires a fair amount of data, some of which is nested through several associations. Therefore, I'd like to pass objects via Mandrill's global_merge_vars, such as the (simplified) following: Which passes through to the mandrill template under the The problem is, I can't access anything within It's not an option to break out data into a large number of variables, as some elements are collections and their associations. I believe the problem occurs as everything is stringified when the variables are compiled for Mandrill -- therefore breaking the JSON object -- with the following a snippet of what is sent across: I can't seem to find any documentation / suggestions for dealing with this, so am wondering whether this it's possible to pass data of this nature, and, if so, how to correctly pass it to be able to access the objects in the Mandrill template. Any advice greatly appreciated! Steve. |
getting weird error in rails console Posted: 06 May 2016 04:19 AM PDT when i trying to perform any of help me solve this thank you. |
Rails 4 unpermitted params error Posted: 06 May 2016 06:23 AM PDT I am receiving this error when a form submits: I can confirm that the params come in ok but it looks like the postal_address_type_faos is being removed. This is the params whitelist: Models: View code from the address partial is something like this Params coming back as: |
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 |
awesome post presented by you..your writing style is fabulous and keep update with your blogs Ruby on Rails Online Course
ReplyDelete