Validation doesn't work as expected for related models in Rails 4? | Fixed issues |
- Validation doesn't work as expected for related models in Rails 4?
- Pundit scoping usage empty results
- Rails + Angular JS + Socket IO
- Create Metafield for product in shopify rails
- subqueries as columns in select same table but different condition and result
- rails nginx and puma error
- Rails / Shared strong parameters' definition between two controllers
- How to elegantly return hash with one value modified in Ruby?
- How to access spree commerce website from external IP address on google compute engine
- How to connect two tables by using ActiveRecord?
- The bucket you are attempting to access must be addressed using the specified endpoint
- How can I make a dropdown menu in rails with the option to display an image?
- Rails 4 ActiveRecord Exclusion Validation for Association
- Should i make a seperate app to send push notifications to 40-50k users in RoR App or use background jobs
- Ruby on rails - Simple form not displaying errors for radio select. Other errors display fine
- Time in DB compared to current time
- Can't install rails-assets-tether
- Foundation CSS with Rails - restricting certain JS elements from loading
- I cannot get assets to work in Rails application
- Cannot generate anything because of Devise [duplicate]
- coffeescript class - calling calling one class method from an other
- When I run Rails Console it says "Switch to inspect mode"
- Ruby: Confused about how to make sense of this code
- create table rows of 4 in rails
- webrick using ssl whats to do?
- ruby on rails: how to add Device
- Rails change root-path
- moving rails2 to 4 and getting error - undefined method `with_scope'
- How do I model Child belongs to class
- Rails Ajax dropdown menu - no response
Validation doesn't work as expected for related models in Rails 4? Posted: 11 Jun 2016 05:38 AM PDT I use one form to enter data for two models. When I save parent model (Tenant) the child model (User) also gets saved, but only if I don't validate tenant_id in User model. If I do Tenant model: User model: Tenant controller: |
Pundit scoping usage empty results Posted: 11 Jun 2016 05:36 AM PDT Suppose I have a scenario where we have I'm trying to limit the The problem I am facing is, perhaps I'm misunderstanding on how to use Scopes in Pundit. My My Pundit Scope class looks like this: In my Rails test, I am trying to assert that non-project owner should receive a 403 forbidden: My test is failing. I am getting the error: I don't quite feel like I'm using Pundit correctly. Should I be using Pundit's I was expecting the |
Rails + Angular JS + Socket IO Posted: 11 Jun 2016 05:13 AM PDT I try to connect my Grape API + Angular JS to socket.io and I have got some errors, preventing me to do it. Can you please help me? I have downloaded this client https://github.com/socketio/socket.io-client. And also this plugin https://github.com/btford/angular-socket-io. Added to my app.js dependency 'btford.socket-io'. And created factory But I continue to get same error: ActionController::RoutingError (No route matches [GET] "/socket.io") I did not include line script src="/socket.io/socket.io.js" I included only socket.js and socket.io.js to my lib |
Create Metafield for product in shopify rails Posted: 11 Jun 2016 05:00 AM PDT I am new to shopify application development and working on to create app which add time block on product page. I have created rails app with form on home#index page as below So when admin select checkbox and submit, a metafield should be created for above product. But it always return error 500 on form submit even though save_product_options path exists in application Please suggest any direction |
subqueries as columns in select same table but different condition and result Posted: 11 Jun 2016 05:03 AM PDT I have two tables So I'm trying to create a view to show the orders along with its closest stocks enter_on like this (I'm using include_after and include_before to give an overview on which date I want to exclude the item that's preordered, so the stock would reflect correctly) include_after is always going to be the stock that came in but not expired yet, if expired, show NULL, include_before will always show the next incoming stock enter_on, unless there's an expire_on that's earlier than the next enter_on So this is what I came up with It works fine (I haven't included the expire_on part), but I'm worrying about performance issue for using two subqueries in the select. Does anyone have some alternative suggestions? Let me know if the question is unclear, the problem is a bit chaotic. Thanks! |
Posted: 11 Jun 2016 04:44 AM PDT I've just deployed a new app and got some errors. my config files looks like the ones in here: https://www.digitalocean.com/community/tutorials/deploying-a-rails-app-on-ubuntu-14-04-with-capistrano-nginx-and-puma puma log: nginx log: Any idea ? Tkx |
Rails / Shared strong parameters' definition between two controllers Posted: 11 Jun 2016 05:53 AM PDT having two items_controller, one for the api (in app/controllers/api/) and one for the backend (in app/controllers/backend) The strong parameters are quite long (20 fields or something) and prompt to evolve a bit. That would not be impossible to maintain this list in both controllers, but as the needs are more or less the same on the create/updates actions, I'd be looking into sharing the strong parameters definition in a separate file that would be shared to both I've tried to inherit those two with a super controller including only the strong parameter definition : No success, I'm stuck with unpermitted parameters Hope to get some tips on this one here on SO; best |
How to elegantly return hash with one value modified in Ruby? Posted: 11 Jun 2016 04:51 AM PDT I have this method in Rails that returns params: I want to remove whitespace from .. but I think it's a bit not elegant since I have to reference the whole path to a hash that I already calling methods on. Is there a better way? I think this is Ruby question, but Rails answer would be just as valid. |
How to access spree commerce website from external IP address on google compute engine Posted: 11 Jun 2016 04:31 AM PDT I am new to Ruby/Rails/Spreecommerce but eventually following the tutorials that I can find on the internet, I successfully made the Spree commerce shop website on localhost:3000. I am using Google Cloud Platform (GCP) for this custom VM: CentOS7, Apache, MySQL, PHP7, Ruby latest, Rails latest, VNC server to access the VM etc. My question is, How do I access my shop with external w.x.y.z IP that GCP has assigned me? When I access this IP from outside I get the usual Apache working Test page ok (assume on default port 80?). I believe Apache server is running too along with rails server. Currently on VM only, I have the access to localhost:3000 which shows my website perfectly ok. Am I missing some config to tweak, so that the outside world can access on w.x.y.z IP? Once this works then I plan to change the nameservers for my actual domain. I had a look at the pre-made solution like Bitnami Spree but I keep away from branding usually hence using my own CentOS7 from scratch. thanks! |
How to connect two tables by using ActiveRecord? Posted: 11 Jun 2016 05:29 AM PDT I'm trying RoR Active Records with Association. And trying to connect two tables, which is restaurants and restaurant_translations. These are split for multi-language support. Here's the definition of those two tables. And the Models. And then here's the controller which creates my headache. So error shows like this. Could you tell me how to write? @Pavan 's advice causes some another errors like this. BTW, my view is like this. It's .slim file. |
The bucket you are attempting to access must be addressed using the specified endpoint Posted: 11 Jun 2016 04:22 AM PDT I'm using paperclip 5.0.0.beta2 in my latest rails (4.2.6) project. The application is hosted on Heroku. I can upload an image and it seems to be stored in a bucket on Amazon S3. However in the browser the image appears to have a broken url, although it's point to the bucket on Amazon S3, the url is: When I enter this url in the browser, I get an xml page with this error message: It looks like there is an issue with the S3 endpoint. However I set the region (eu-west-1) in configuration file: My Github repository is at: https://github.com/acandael/gigbnb Does anyone have an idea what's going on? Thanks for your help, Anthony |
How can I make a dropdown menu in rails with the option to display an image? Posted: 11 Jun 2016 04:21 AM PDT I want to make a simple dropdown menu which lists some options (for example: tiger and lion). When I press the submit button, i want to reload the page, the dropdown menu should be still there and the image of one of the options (images are in app/assets/images) should be below. I don´t know how to define the change action in the controller, that after pressing the submit button, the page reloads and the correct image is shown. Also i am not quite sure if my dropdown menu is correct. I would be very glad if you have some ideas. Thanks in advance. This is my view so far: This view has a dropdown menu and shows the tiger image. This is the def index of the animals controller: |
Rails 4 ActiveRecord Exclusion Validation for Association Posted: 11 Jun 2016 05:15 AM PDT I'm trying to validate an association in my model and exclude a certain object for the validation, but can't seem to get it to work. Here's my code: I imagine it's trying to do a direct comparison of |
Posted: 11 Jun 2016 05:12 AM PDT I have a rails application that is in fact a backend of a popular IOS application which have a user base of 200k users who need to be notified time to time. Daily 40-50k users will be notified using push notifications. These push notifications will be realtime and scheduled ones. eg: if a new users signs up he will be notified within few seconds. eg: scheduled notifications will run at 10 pm daily with limited users ranging 10k-30k or sometimes more upto 100k. I also will be doing business reporting to generate list of users fulfilling certain criteria and it requires firing mysql queries that could take upto 1-2 minutes of time. My area of concern is should i have a seperate application with seperate mirror db to send push notifications to these users so my IOS users doesnt feel lag while using this application when push notifications are triggered or business reporting query is triggered. Or should i use background jobs like Rails Active job, Sidekiq or Sucker Punch to perform push notifications and triggering business reporting queries. Is background jobs in rails so powerful that it can manage this condition and doesn't let App users to feel lag in experience. My application stack is: |
Ruby on rails - Simple form not displaying errors for radio select. Other errors display fine Posted: 11 Jun 2016 03:56 AM PDT I have a user registration form (Devise) with 4 elements; Username, email, password and 'user type'. User type is a boolean and is displayed as a radio select on the form. Errors for Username, email and password show no problem, but I get no errors showing if a user doesn't select one of the radio buttons. Validation IS in place, and the form won't send without one of the radio buttons selected, but I get no errors. The form: User.rb: Registration works without a problem, my only issue is the error not showing. I'm not sure if it is necessary to paste any more of my code, but if so I'll update with whatever is required. |
Time in DB compared to current time Posted: 11 Jun 2016 03:00 AM PDT I have a couple of stores that I'd like to display if they're open or not. The issue is that I have my current time. and then if I for example take out the so what I have now is: and then I check if a current_business_hour is present. However this is calculating it wrong by what seems like two hours. The open_at and close_at should be within the time zone of |
Can't install rails-assets-tether Posted: 11 Jun 2016 02:50 AM PDT When I try to install This is the part of my Gemfile: Changing I'm using Windows 10 |
Foundation CSS with Rails - restricting certain JS elements from loading Posted: 11 Jun 2016 01:52 AM PDT Foundation is a great CSS framework, but when used with Rails as a gem it loads up a lot of unnecessary js elements, such as accordions, etc: I would like to find a way to get in the middle of this process and remove a bunch of these elements to get a small performance boost. I understand that I need to swap the line in my |
I cannot get assets to work in Rails application Posted: 11 Jun 2016 02:14 AM PDT I just fixed some problems with database in production mode of my Rails application and now I couldn't get any assets to work. Here is the part of production.log: I have app/assets/stylesheet/aplication.scss |
Cannot generate anything because of Devise [duplicate] Posted: 11 Jun 2016 01:27 AM PDT This question already has an answer here:
When I try to use any generator I get an error from It started after I created How do I solve it? |
coffeescript class - calling calling one class method from an other Posted: 11 Jun 2016 01:14 AM PDT I have rewritten my embedded JS in my rails app to coffeescript..and I am new to coffeescript... My approach is a mix of these articles: My code: This is part of a model that gets loded with ajax and once that call succeeds i do i create the above class (instance of): My problem. The modal gets loaded an all seems good. But when I trigger the event: I get: so, it does not know the likePhoto function. I have tried calling this.likePhoto and @likePhoto, but this refers to the button element that triggers the event. So how do I do this? Other approaches are welcome. i not really sure that I need the classes...but I really want structured code... |
When I run Rails Console it says "Switch to inspect mode" Posted: 11 Jun 2016 01:45 AM PDT If I try to access my console or irb git bash says "switch to inspect mode". I followed the answers here & tried installing the readline gem(0.5.3)(ended without any luck) linked here : https://rubygems.org/gems/rb-readline/versions/0.5.3 I'm unable to access the console or irb. |
Ruby: Confused about how to make sense of this code Posted: 11 Jun 2016 02:07 AM PDT I'm a little confused about one part of this code. In line 7 I have commented below. Line 5 is and example of what each line is like in the states_abbrev.txt file. Just a state, a comma, abbreviation, and a carriage return. All 50 states are in the file. As you can see on line 7 the data[0] key seems to be overwritten by data[1]. So why is it when i run this code data[0] is still the key, and data[1] becomes the value? |
create table rows of 4 in rails Posted: 11 Jun 2016 01:18 AM PDT I have these checkboxes, I'm trying to create rows of 4 checkboxes. At the moment it creates one row. Iv have tried something like this: Im trying something like this to iterate over and every time is counts to 4 in trying to generate a new row, but I'm not sure how to complete this. |
webrick using ssl whats to do? Posted: 11 Jun 2016 12:36 AM PDT I've got a rails 4 application and I want to run it with SSL on webrick. what do I have to do? I've added the ssl certificate for the domain and startet like this bundle exec rails s -e production -p 3001 --binding=0.0.0.0 Now I got this error: Thanks |
ruby on rails: how to add Device Posted: 11 Jun 2016 12:34 AM PDT I want to get rid from unwanted users using Ruby on Rails. There are several options to do this using Device. How to add Device to Ruby on Rails? thanks. |
Posted: 11 Jun 2016 12:13 AM PDT I have thingspeak server working on http://portail.lyc-st-exupery-bellegarde.ac-lyon.fr/srv3, witch is behind a proxy server. how can i tell rails to add "srv3/" to all url ? thanks |
moving rails2 to 4 and getting error - undefined method `with_scope' Posted: 11 Jun 2016 01:22 AM PDT How to replace this Query in rails4.1.9 Getting Error undefined method `with_scope' . |
How do I model Child belongs to class Posted: 10 Jun 2016 11:31 PM PDT This is the schema I have for the Should I need to create 12 different models, from Class1 to Class12 and all will have belongs_to Child class? Is there an efficient way to to do this? |
Rails Ajax dropdown menu - no response Posted: 10 Jun 2016 11:38 PM PDT So I've solved almost all my problems with this little program I'm writing: The only one left, that I'm just beating my head against, goes like this. It's your standard two dropdown menus, select an item on one to populate the other. In my view: In my controller: In my application.js: In my routes: And I just don't get anything at all populating company.id. Not ever! Contractor.id populates just fine, all the names fill out there, but nothing is returned to company.id I'm a huge noobie, so I'm sure I'm missing something here. What?? |
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