Rails: Validate only the fields that are within an array | Fixed issues |
- Rails: Validate only the fields that are within an array
- Is it possible to use embedded ruby in tests?
- Mongoid update column with unique token
- Passing clientX and ClientY variables in Rails
- Activerecord or SQL - update each record with an incremented value with a single statement
- How to test controller without hitting the database?
- Simple Form bootstrap customize collection_radio_buttons field
- Rails - What can cause a mouse cursor gap in textinput?
- gem install rails fails on nio4r windows7 ruby 2.3
- Traversing an array with special characters Ruby
- Rails Cucumber Testing - Send form data to method
- Setting a variable with an alternative value if other options are blank
- How to add/implement SendGrid if the app is not deployed/hosted on Heroku?
- Controller test with RSPEC and FactoryGirl fails with error expected: 1 got: 0
- filepicker_rails re-bind new filepicker_field elements
- Separating posts in a newsfeed using CSS/BootStrap
- Rails: How can I load new values into a form on edit but only persist them on save?
- Ruby - Accessing parent application title from an engine
- icon as the main button in rails form
- Ability for users to sign up via SMS (Rails)
- rails rspec capybara select not working
- Rails POST to Google Calender API via rest-client gives 'bad request' error
- HTML JavaScript hide/show button
- Rails - Group by 2 date columns
- nginx: use different server for different path
- How to use exists filter in an aggregation for elasticsearch in ruby
- Issue regarding parsing a file in ruby on rails
- What will be the RSpec test case for devise invitation controllers edit and update method
- How to connect one model to another more than once?
- Rails; sum total
Rails: Validate only the fields that are within an array Posted: 09 Dec 2016 08:09 AM PST I am attempting to validate a model based on a serialized array stored in a separate model that it is referencing. If the user selects that option from a dropdown if will retrieve the serialized array from the other model. I have been able to get this to work, I just cannot seem to build a simple validator. I would like to validate it as long as the field is in the array. The fields range from simple strings to integers and decimals. I have been trying to build it in a manner such as this: But so far I keep getting this error: Thanks |
Is it possible to use embedded ruby in tests? Posted: 09 Dec 2016 07:55 AM PST I used embedded Ruby in fixture to create n objects: Is it possible to use embedded Ruby in tests, in order to test the above n objects? |
Mongoid update column with unique token Posted: 09 Dec 2016 07:30 AM PST Let's take a look at the following code for ActiveRecord It enforces a unique token across the table. Therefore even with small codes (eg. only 5-6 letters) we can ensure uniqueness by retrying. How do I achieve the same on Mongoid ? |
Passing clientX and ClientY variables in Rails Posted: 09 Dec 2016 07:40 AM PST I'm working on a photo tagging project where a user clicks an area of the screen, a box appears around that area, and a they then select from a list of characters that they are supposed to find. At the moment, I can get the box and list of characters to appear using Jquery in my rails app. When the user clicks the name of the person they are guessing, it sends an ajax request to the server to check a few things out. This is where I run into trouble: One thing I'm checking for is to see if the character falls inside of the box that was created on click. Each character has an X and Y coordinate attribute stored in the data base. My question is: How can I take the clientX and clientY information I gathered when the user clicks and use it to see if the XY coordinates in the data base match? I've included the most relevant code below. I know I should separate my js out of the view, but I plan to do that when I refactor. Thanks for the help! |
Activerecord or SQL - update each record with an incremented value with a single statement Posted: 09 Dec 2016 08:03 AM PST I have a cards table with an attribute called 'position', which has a default value of 0. I need to select a group of cards, then assign the position of each card with an incremented value. So, lets say that I select a group of cards using Can a single Activerecord or SQL statement assign an incremented value, that would give a result like this? |
How to test controller without hitting the database? Posted: 09 Dec 2016 07:06 AM PST I have a controller: I want to write a test but without hitting the database: Is there a better approach? I don't like this chain of I could obviously just create the invoice in the DB and don't bother about all the mocks and stubs. However, doing this in all the specs would slow down the whole test suite. |
Simple Form bootstrap customize collection_radio_buttons field Posted: 09 Dec 2016 07:18 AM PST I have this collection_radio_buttons field which has been customized a bit to show icons, but now for some reason the error span tag is not showing anymore. Also i would like to get rid of the label wrapper around each input itself. Perhaps i would have to create a custom block in the initializers file? or maybe i am missing something in the block? Here is my code |
Rails - What can cause a mouse cursor gap in textinput? Posted: 09 Dec 2016 06:57 AM PST I'am bit new in rails, and this is my first big project, so i'll try to make simple for avoid confusion. I got a text input And, when I post, (press enter, click on button continue, press space for auto-completion), after the page is updating, the mouse cursor (carpet) is 2 chars away from the last word typed, like if it was padded with spaces. However, the value of the text does not contain the unwanted spaces. I've tried all the stackov post like I'am completely lost for 2 days, ty for any clue. |
gem install rails fails on nio4r windows7 ruby 2.3 Posted: 09 Dec 2016 07:15 AM PST Trying to install rails on a windows 7 machine: rubygems -v 2.5.2 ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32] installed ruby installed devkit Then> gem install rails (I'll get the following error) Failed to build gem native extension windows 7 |
Traversing an array with special characters Ruby Posted: 09 Dec 2016 06:38 AM PST I am getting an array from ldap server... which is not syntactical correct. is there any way to traverse or get useful values out of it..?? Thanks in advance Editing my question for adding more info app/models/user/ldap.rb and then I am printing returned array in view and getting that weird array |
Rails Cucumber Testing - Send form data to method Posted: 09 Dec 2016 07:02 AM PST I'm trying to send form data, from cucumber test, to controller method. I have a form with login & password fields, and submit button. In cucumber step, I input values in that form (login fields not shown, but similar). So now login and password values are set. And my authenticate method gets called as it should, but its parameters are empty. When I input values normally on the webpage, everything works fine. Why doesn't the cucumber version work? All my cucumber steps pass!! so im confused How can I send data from textfields to controller method? Thank you |
Setting a variable with an alternative value if other options are blank Posted: 09 Dec 2016 06:03 AM PST I have a variable that must be set with a phone number, preferrably with a value from table A. If that's empty, it should be a value from table B (which is related to table A). If that's empty as well, it should be a value from another column on table B. Finally, if all of these are empty, it should be set to a string. I tried to do this with But the result is I wanted to avoid nested |
How to add/implement SendGrid if the app is not deployed/hosted on Heroku? Posted: 09 Dec 2016 05:48 AM PST When the app is deployed on Heroku, the command to add/implement SendGrid is:
I am planning to deploy my next rails app on a DigitalOcean/Nginx/Passenger/Capistrano setup. My question is, how do I add/implement SendGrid to my app now? |
Controller test with RSPEC and FactoryGirl fails with error expected: 1 got: 0 Posted: 09 Dec 2016 06:01 AM PST The model My This is my This is my Based on the above I am assuming that an My test is failing with this error. Don't know how to fix it and have the test passed? |
filepicker_rails re-bind new filepicker_field elements Posted: 09 Dec 2016 05:40 AM PST I'm using Filepicker in a Rails project via the Everything works fine, but with this particular UI, there are cases where I need to dynamically add new I'm not sure what the issue here is, but I'm guess these new elements need to be rebound to the filepicker js, but I do not know how this can be achieved with the gem. Any thoughts would be appreciated. |
Separating posts in a newsfeed using CSS/BootStrap Posted: 09 Dec 2016 07:01 AM PST I'm currently trying to render a newsfeed, similar to that of FB on a Rails application I'm working on. Unfortunately, I'm not the greatest when it comes to CSS and I'm having some issues trying to display different posts. This issue occurs whether I'm using BootStrap or plain CSS. I do believe it's something to do with the loop that is created by Image: Any help would be greatly appreciated! Thanks. Edit: OK, please take a look at the new image -- hopefully that will make the issue slightly more obvious. Additionally, I've removed all the dead tags and replaced them with just one: BootStrap's 'well' class. So, there you have it. All the information you need is within the code above. |
Rails: How can I load new values into a form on edit but only persist them on save? Posted: 09 Dec 2016 06:11 AM PST I've got a Rails 4 app with a service that loads required objects on a new/edit document action, and this is a method from it: I need a solution for the two problem lines (they are just two things I've thought of, and they aren't supposed to both be there but I've included both for the sake of my problem). The first updates and persists the change to the model which is behaviour I don't want. The second line doesn't do anything, where logically it seems like it should replace whatever text was in that variable in the form with Is there are solution to this problem that I'm unaware of? Bonus points if there's a way to list the fields with new values to display in a Update now with relevant form code. Setting the value/vs not setting it doesn't change anything either. |
Ruby - Accessing parent application title from an engine Posted: 09 Dec 2016 05:21 AM PST I'm creating an engine which pulls a copy of the parent app's SQL database. I'm trying to create a method which reads the title of the parent app to use in the title - what is the easiest way to do this? Most times I've seen this question asked the answers seem to advise that this isn't best practice, if that is the case then how should I go about getting what I need? Thanks. |
icon as the main button in rails form Posted: 09 Dec 2016 05:25 AM PST My problem is quite simple. I just want the icon to be the button. No borders. I've tried button_to but somehow it produces the icon inside the button. I've also tried link_to and it looks good but then this is gonna be used to submit a form. It's quite simple but somehow I can't get the behavior that i want. Here are my attempts at this: Thanks in advance! |
Ability for users to sign up via SMS (Rails) Posted: 09 Dec 2016 05:29 AM PST I am working on a rails application where the main user model is authenticable by mobile number and a password. This all works fine through the website. What I would like to do is enable a user to access all the same functions of the web app using solely an old school cell phone - that is purely via SMS. I have already enabled some of the web app functions via SMS using Twilio but I was unsure how to go about handling the creation of a user password via SMS in a secure manner. What I would like:
I imagine my TwilioController action will look something like this: I am already familiar with how to set this up on my Twilio account using TwiML apps - I am only interested in understanding how to manage the password aspect of this problem! Thanks EDIT: I have seen that Devise provides the method #friendly_token. Is this something that would be useful in this case? |
rails rspec capybara select not working Posted: 09 Dec 2016 07:49 AM PST In my rails app, I have a select on the navigation bar as follows: and javascript in application.js to load the home page when the user selects a different option. I have written the following test for this feature using rspec, capybara and capybara-webkit: save_and_open_page results in the html snippet as shown above. The result of running the test is as follows: If I use My versions are follows (from and What do I need to do get this test to work? Should I be using a different test platform? We are relatively committed to rspec but less so to capybara. |
Rails POST to Google Calender API via rest-client gives 'bad request' error Posted: 09 Dec 2016 04:36 AM PST I've searched many other questions and I don't see that I'm doing anything different, but rest-client will not work when trying to post a new event to Google API |
HTML JavaScript hide/show button Posted: 09 Dec 2016 05:08 AM PST I'm working on a little Ruby on Rails application and I'm trying to add a hide/show button which hides a div with some Id. I've followed the steps from this post and it hides the content (second answer). The problem is that the content is not hidden permanently. Once I click in the button, the content dissapears, then the browser do something like an auto refresh and the content appears again. Could anyone help me with this? It is my first application and my background in javascript is quite poor... A piece of the code I want to hide/show is the following: and the javascript of the button is: Thank you in advance. |
Rails - Group by 2 date columns Posted: 09 Dec 2016 04:28 AM PST Using Rails and PostgreSQL how can I group by two DATETIME columns? I want to format a string based on the weekdays of a establishment is open Eg: MON-FRI 10:00 - 22:00, SAT-SUN 10:00 - 18:00 I have this model |
nginx: use different server for different path Posted: 09 Dec 2016 05:16 AM PST I have two Rails applications sitting behind two different URIs on the same machine. The nginx configuration is for each application in an own configuration file. Now one of the applications has to be slowly merged into the second one. There is an endpoint accessible under the URI path Is there a way to do this without using 301 Redirects since I am not able to use them in my case? An example configuration file looks like this: |
How to use exists filter in an aggregation for elasticsearch in ruby Posted: 09 Dec 2016 03:30 AM PST I am using elasticsearch-ruby gems, and I am trying to get the number of retweet in an aggregation. I am using the following DSL query: So I try to use the 'exists' query ( https://www.elastic.co/guide/en/elasticsearch/reference/5.0/query-dsl-exists-query.html )but it seems that exists filter can not be used in this contex, I got the result: |
Issue regarding parsing a file in ruby on rails Posted: 09 Dec 2016 05:50 AM PST I have a text file (.txt) which contains an array and the elements of these array is in string format but these are also arrays. Just like the following: For example, lets consider my file as: Now I want to parse these file and I need to print the data in the following format as: Now , I just don't know where to start. I know how to parse a text file in ruby but this time its containing an array. So I am confused how to start and did not get the right idea yet. Please help me by giving me some hints. Thanks in advance!!! I am using the following code to store the content of the file into the array. But it is not giving me the proper format. My file contains array in a contiguous manner. There is no new line in it. I think it causing the problem in the following code. |
What will be the RSpec test case for devise invitation controllers edit and update method Posted: 09 Dec 2016 04:18 AM PST I am not able to go in my invitation controller edit method, I have tried everything but not able to go in edit method. Here is my edit method test case: |
How to connect one model to another more than once? Posted: 09 Dec 2016 03:41 AM PST I have quite a specific problem so I'll translate it into more understandable and clear example. So we have 'Country' and 'Image' models. A Country has its flag and its arm. This means we have to connect Country to Image 2 times. I tried transforming Rails guide's recipe 'Connecting to itself', however, I always get an exception: "Image expected, got String". |
Posted: 09 Dec 2016 04:05 AM PST I'd love to refactor the code below in more like Ruby way. Basically just iterate object, fetch the each amount, and return the total. Any idea? update
|
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