Polymorphism ignored by mongoid | Fixed issues |
- Polymorphism ignored by mongoid
- How do I screen for integers that are too big in my Rails model?
- Why the server boots up multiple sidekiq processes? How to put them down?
- How to build own class with behavior like ActiveRecord_Relation
- Ruby on Rails db migrate error while loading the hoe gems
- Modifying migration column not loaded in migration rails
- Why postgres calculate percentage wrong (based on columns result)
- underscores are converted into hypens in rails headers?
- I have one php theme with all files of .php extension now i want this all in .html extesnion to integrate to my ruby on rails project. any solution ? [on hold]
- How to check if a date of a booking is overlapping rails hotel application
- Rails 5 Unpermitted Parameter Upon Save
- Opentok streaming not showing on the client's end
- Put text in helper method, but the caluclation is in float
- When installing elasticsearch and running the Searchkick's reindex command, do I need to be inside the master branch?
- How to develop and deploy Angular2/Rails application(integrate Angular2 with Rails)?
- bxslider isn't displaying images until page resize with responsive design
- Ruby: starting thin as deamon returns Bad File Descriptor
- capybara visit url with reserved character
- search bar using MaterializeCss and Ruby on Rails
- Check if record exists where child has value
- What is the difference between these two line.? [duplicate]
- Getting the oldest datas from a table that are older than a 100 days
- how to keep secrets.yml, so as to build my raills app by semaphoreci.com?
- Rails Oauth2 authorization modify
- Ruby On Rails Website Using Schema Diagram
- extract single cases from array
- Rails (Puma & Passenger) can't find bundled gems after deploying with Capistrano
- Storing periodicity in Rails
- Validation for date/times that overlap
- Two different show views for restful resource in rails
Polymorphism ignored by mongoid Posted: 12 Dec 2016 07:45 AM PST In a nutshell I run into the following error with validations / model saving
Full Background & class code I am trying to implement a referral system. I want to keep a separate On the user side it begins quite simple : the following module is included into My app supports many user profiles. For instance Note that I don't have a base class Now things are getting nasty. I want to keep track of which UserProfile referred which other UserProfile. So I have to fight with polymorphism First the extension for the And the profile extension (included in So far so good, but then I get the following problem : when I validate the Referral model, I run into
|
How do I screen for integers that are too big in my Rails model? Posted: 12 Dec 2016 07:38 AM PST I'm using Rails 4.2.7 with PostGres 9.5. I have this column in my Rails migration ... In my model, I would like to screen for numbers that are too big and set them to nil. For instance, the number "659722222222222" is getting set on my model and is causing the below error Rather than save the model, I would like to set the field to nil only if it is set to an integer value that is too big for PostGres SQL. How do I do this? Note, I do NOT want to change teh column type of the PostGres column. You didn't think this was going to be that easy, did you? |
Why the server boots up multiple sidekiq processes? How to put them down? Posted: 12 Dec 2016 06:52 AM PST I deployed a rails app with puma(3.4.0) and sidekiq(3.0.2). Almost all of the configrations are default value by capistrano-puma and capistrano-sidekiq. But I don't know why multiple sidekiq processes turned up and occupy the memory. Screenshot of htop: enter image description here Sidekiq has concurrency feature so that i only want one sidekiq process. Any help with this? Thanks in advance! |
How to build own class with behavior like ActiveRecord_Relation Posted: 12 Dec 2016 06:51 AM PST Please look on example for understanding what I mean: class UserPlaces def initialize(user, country) @base_query = user.places.where(contry_id: country.id) end def with_positive_rating @base_query = @base_query.joins(:place_ratings).where('place_ratings.value > 0') self end def order_by_name @base_query = @base_query.order('places.name ASC') self end def filter_by_group(group) @base_query = @base_query.joins(:group).where(groups: { id: group.id }) self end def fetch @base_query end end In this case I can use: UserPlaces.new(user, country).with_positive_rating.fetch UserPlaces.new(user, country).with_positive_rating.order_by_name.fetch UserPlaces.new(user, country).filter_by_group(group).order_by_name.fetch ... I want to do the same but without "fetch" method. Something like using scope for model instance. Anybody know how I can do that? Thanks. |
Ruby on Rails db migrate error while loading the hoe gems Posted: 12 Dec 2016 06:18 AM PST I have been having this problem the whole day. whenever i try to do a rake db:migrate command on rails i keep getting this error. "error while loading the hoe gem. Please install it by running the following: $ [sudo] gem install hoe". But everytime i run and update all my gems i still get the same error. The hoe gems i have already installed is the latest version (hoe 3.15.3) Please help. Am running rails 5.0.0.1this is the error i keep getting |
Modifying migration column not loaded in migration rails Posted: 12 Dec 2016 07:23 AM PST I added two migration which in the first one I add a column to a model, and in the second one, I execute a function that stores a value into the column recently added of some rows. The problem is that when I run rake db:migrate the second migration throws an error because the first migration was loaded but the database hasn't changed yet, so one approach is to run the command twice (it works). First Migration : Second Migration : the OneClass.perform is a method that makes an update of the attribute added previously The error thrown :
Note that the method undefined is the name of the attribute added previously. I wonder if there is a way to avoid running the command twice without throwing any error. |
Why postgres calculate percentage wrong (based on columns result) Posted: 12 Dec 2016 05:37 AM PST I am trying to get % of discount between two columns, first problem which i was solved is that other column may be 0 or null, Now when I calculate it it always give me 100 or 0 as a result of column 'discount' All the results was 0 or 100 :\ Tried to solve with sub function but still gave me same wrong percentage. |
underscores are converted into hypens in rails headers? Posted: 12 Dec 2016 07:19 AM PST Hi I have restful apis in rails and react-redux at front-end.. At front-end: i.e I have sent two parameters from client-side
What I'm Getting at rails server At my console I'm getting but getting values in underscores are getting converted into hypens |
Posted: 12 Dec 2016 04:38 AM PST I have one php theme with all files of .php extension.Now i want this all in .html extension to integrate to my ruby on rails project. any solution ? As, how to convert php theme to html theme ? |
How to check if a date of a booking is overlapping rails hotel application Posted: 12 Dec 2016 06:20 AM PST I'm making a web application in Ruby on Rails for a hotel. I've seen some questions around that may look the same as mine, but I couldn't find the right solution. A user can create a booking and choose which room they want and what day they are arriving and leaving. Everything is working as the way I want except of the fact that my rooms can be booked with overlapping dates. Schema: Controller Model of booking What I want When a user tries to create a booking they should not be able to choose a certain room that is already booked at the days they want to sleep in the hotel. |
Rails 5 Unpermitted Parameter Upon Save Posted: 12 Dec 2016 04:29 AM PST I'm working with two models However, I'm getting the error: From my log: Perhaps I'm just rusty and am overlooking something or does rails5 have a new trick to dealing with strong params? Thanks in advance! |
Opentok streaming not showing on the client's end Posted: 12 Dec 2016 04:06 AM PST I'm currently studying Ruby on Rails and would like to create a live video session. I've followed through a tutorial I found but I only managed to have the video available for the one who is streaming (/users/:id/streams/:id), but not the ones who are watching (/users/:id/streams/:id/view). Here are the codes I've included for this feature: Stream Class View Class Stream Controller View Controller Stream View Viewer's View Routes Stream Coffeescript View Coffeescript Somehow the coffeescript for the view is not loading and I'm not sure why. Any help on this would be greatly appreciated. Thanks! |
Put text in helper method, but the caluclation is in float Posted: 12 Dec 2016 04:22 AM PST Hi I have a helper method for some calculations, I want to put some text but when I call this method the after calculation is in float. I want to put text how can I do this? Any idea? thanks! |
Posted: 12 Dec 2016 04:51 AM PST Should I be inside the master branch when installing Elasticsearch and running the Because all the tutorials I found are inside the master branch, but when I'm adding a feature to my app, I always checkout on other branch and just merge it if the feature works. |
How to develop and deploy Angular2/Rails application(integrate Angular2 with Rails)? Posted: 12 Dec 2016 03:41 AM PST Now I'd like to use Angular2 to develop the frontend, and use Ruby on Rails to develop the backend. I know I can create a Rails app using RubyMine IDE, and create an Angular2 app according to the documentation from angular. But how should I integrate the Angular2 app with the Rails app. How do I modify the Rails source to include the Angular2 source. This link just changed Someone said I must convert |
bxslider isn't displaying images until page resize with responsive design Posted: 12 Dec 2016 07:22 AM PST I am trying to implement bxslider on a responsive page (using Bootstrap) and for the first 2 or 3 times it is showing images correctly. However after that it just shows a narrow white band: If I resize the browser then the bxSlider resizes correctly and displays the images. My partial code contains the following code (Note, this populates a div as a result of an AJAX call) The bxslider setup is working correctly as I do always get the expected output to console. I have replicated this behaviour in Safari, Chrome and Firefox. From my searches most people who have had resize issues with bxslider were having issues when resizing the browser, not on initial load. Edit Setting an initial fixed height for the layout of the bxslider displays all images at once (including 2 extra - which I assume are for buffering the navigation). Again only a browser resize forces the bxslider to resize and display correctly. This is suggesting that perhaps the issue isn't, as I originally believed, a result of misbehaving with responsive layouts. Perhaps the following information is pertinent to this question. I am using Rails and the page I posted earlier is a result of an AJAX invocation of ProductsController#show show.js.erb _show.html.erb as posted at start of question invocation |
Ruby: starting thin as deamon returns Bad File Descriptor Posted: 12 Dec 2016 03:17 AM PST Starting the Ruby thin client works fine in command line: But starting it as deamon returns a Bad File Descriptor: Any idea? This happened without any code change. There is also nothing already running. |
capybara visit url with reserved character Posted: 12 Dec 2016 03:13 AM PST I want to visit a url returned from an API. Url looks like this: When I call visit on this Capybara returns How do I make it work? |
search bar using MaterializeCss and Ruby on Rails Posted: 12 Dec 2016 03:06 AM PST I have this form for searching: how can i make something like that: search_bar ? |
Check if record exists where child has value Posted: 12 Dec 2016 03:24 AM PST I'm building an interface where people can submit tags for the content of various websites so each The trick is that I would like to check to see if that tag has previously been submitted for that domain before saving. Something like: |
What is the difference between these two line.? [duplicate] Posted: 12 Dec 2016 02:55 AM PST This question already has an answer here: I am not able to find the difference between these two line. If anyone know please clear this. Thanks in advance. |
Getting the oldest datas from a table that are older than a 100 days Posted: 12 Dec 2016 03:33 AM PST I've been struggling with the following problem: EXPLAINING I have a table called I need to archive the any data older than a 100 days. But since there's a lot of data (they arrive each 5 or 10 minutes) and we have more than 1000 parts, I need to do it the 5 oldest days each time. This is the schema of my table: So basically I need to get all data that is in this table, where produced_at is prior to 100 days ago and limit that to the first 5 days, per part. Example:
100 days ago would be 3 Sep 2016. For WHAT HAVE I TRIED Well, I'm using rails on this, but a SQL solution is welcome as well. For now, What I'm doing is to grab the oldest data with: And then I loop Over each part_id and grab the data based on the Any idea? |
how to keep secrets.yml, so as to build my raills app by semaphoreci.com? Posted: 12 Dec 2016 07:14 AM PST I created my rails app. Then I didn't know , but I need to add secrets.yml to .gitignore and I put it to my repository. I joined the rails app to semaphoreci.com. When I committed semaphoreci.com builded ok. Later I removed secrets.yml from my repozitory. I did: Now semaphoreci.com don't works. I got: I think,it happens becouse repo don't contain secrets.yml. I read that I need to keep secrets.yml outside repo. How to keep secrets.yml for semaphorecy? I tried to use dotenv gem, but I think that if I will add to .gitignore .env file and will add secretts.yml to my repository with code: but I think semaphorecy will not build, becouse in repo ENV['secret_key_base'] will find .env file, or not? I don't understand, how can I store my secret_key_base in repository so as to semaphoreci can find it and launch rails server. |
Rails Oauth2 authorization modify Posted: 12 Dec 2016 02:48 AM PST Recently, I want to implement an authentication system that allow other companies create bunch of users in our service. I read many references about But I think my authentication system now would not contain the step (B), (C) and (D). However, I think in far future, my service should surpport 3rd party access, which means I need the step (B) to (D). My question is that, is there a greater implementation that match my first require? Is there a easier way to scale authentication system? BTW I use |
Ruby On Rails Website Using Schema Diagram Posted: 12 Dec 2016 02:19 AM PST I am learning ruby on rails. I want to build a website for the below schematic diagram: Schema. What are the steps I should follow to build it ?. A tutorial online with schematic diagram would help. I want to know: 1) How to give primary and foreign keys ( I am using sqlite database) ? 2) How to give associations ? 3) How to query ? Thanks guys for the help. |
extract single cases from array Posted: 12 Dec 2016 02:48 AM PST An array of records being generated by will have actions with one or more signatures. What ruby instruction can extract just the single cases, based on action_id? |
Rails (Puma & Passenger) can't find bundled gems after deploying with Capistrano Posted: 12 Dec 2016 01:51 AM PST I've been working through the PragProg Agile Rails 5 book. I'm hung up on the deployment. I did a straight copy/paste deploy locally with Apache. When I deployed with Capistrano, however, the deployment completes without error, but running I've ran Here's the what I got in the D, [2016-12-12T18:47:37.353437 #12570] DEBUG -- : [1m[35m (0.2ms)[0m [1m[34mSELECT DATABASE() as db[0m D, [2016-12-12T18:47:37.353879 #12570] DEBUG -- : [1m[35m (0.2ms)[0m [1m[34mSELECT GET_LOCK('2754433143543187260', 0);[0m D, [2016-12-12T18:47:37.365473 #12570] DEBUG -- : [1m[36mActiveRecord::SchemaMigration Load (0.5ms)[0m [1m[34mSELECT `schema_migrations`.* FROM `schema_migrations`[0m D, [2016-12-12T18:47:37.375988 #12570] DEBUG -- : [1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1[0m D, [2016-12-12T18:47:37.379731 #12570] DEBUG -- : [1m[35m (0.2ms)[0m [1m[35mBEGIN[0m D, [2016-12-12T18:47:37.380950 #12570] DEBUG -- : [1m[35m (0.2ms)[0m [1m[35mCOMMIT[0m D, [2016-12-12T18:47:37.381305 #12570] DEBUG -- : [1m[35m (0.2ms)[0m [1m[34mSELECT RELEASE_LOCK('2754433143543187260')[0m Apache just says "Incomplete response received from application" when I visit |
Posted: 12 Dec 2016 04:37 AM PST I am giving users an option to receive, say, emails at a periodicity of their choice, for example: or or even What would be my best choice for storing this kind of data in order to feed it to Update I was able to solve the question with @mudasobwa 's advice in combination with the
|
Validation for date/times that overlap Posted: 12 Dec 2016 01:57 AM PST In my rails app I have a model called Currently, I have a validation that checks whether the date and time combination already exists, and if it does then it raises an error. The problem I am having is that each booking lasts for a certain time period, say 4 hours. Obviously I cant have a user booking at 8.30am, and another one at 9am, although my validation currently allows that. I want to be able to check:
For example, A user books for 2016/12/20 at 8.30am. The booking lasts for 4 hours. Another user tries to book for 2016/12/201 at 10am, but because the booking is in the range of 8.30am-12.30am (4 hours), then it doesn't get validated. This is my validation method currently: This is another one I have tried, although it only checks for the end of the booking period: The How am I able to check whether the new booking is in the range of other bookings and their times? |
Two different show views for restful resource in rails Posted: 12 Dec 2016 01:36 AM PST I have a job app with two kinds of (not-authenticated) users, referrers and candidates. Currently I have 1 jobs controller and model. Basically, I want to have two routes: Both routes are public, there are no logged-in users. While the model data (=content) is very similar for the two routes, the views are obviously different. I am struggling to create two different show views within the same controller. I have looked at setting up a separate namespace (seems to be for the entire controller), specific get routes or setting up a separate controller, but really not sure what the best "Rails" way is. Any suggestions would be really helpful, thanks in advance! |
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