How to nest namspaced resources and avoid double namespacing - uninitialized constant ActsAs::ActsAs | Fixed issues |
- How to nest namspaced resources and avoid double namespacing - uninitialized constant ActsAs::ActsAs
- Running rails project on heroku
- comparing one element in an ActiveRecord array to all others ruby on rails
- wkhtmltopdf not corresponding size after generating pdf Rails
- Whitelist params - how to allow n level nesting of self relationship?
- How to Encrypt data in ruby same as SecretKeySpec?
- ActiveJob with Resque plugins
- Cant use class defined inside lib folder in rails app
- Capistrano deployment broken by new request for Capistrano-Harrow gem?
- How to get the records where status is equal to nil and not equal to privilage or casual
- Rails date check if parsable
- How can I verify username or email are correct using Devise and Rails 4
- How to convert all daily datat of a year to monthly data
- Generate array of daily avg values from db table (Rails)
- How to use order with uniq in a PostgreSQL
- rails 4 partial extension required under pdf template
- Error R13 (Attach error) -> Failed to attach to process on running console on heroku
- ruby on rails rest api with ruby for login page
- Cannot use password grant_type on 4.0.0 RC3 using Rails 5 Beta
- How to show entries from the current month?
- Ruby issue while configuring sensu checks
- capistrano excute Makefile fail
- Unable to establish relationship between two objects in Rspec
- Unable to download .docx file using Capybara in ruby [duplicate]
- belongs_to with different foreign key as well as primary key in the other table
- Create a auth user using devise
- Elasticearch result only on the basis of Term Frequency,avoiding Inverse document frequency and Field-length norm
- .docx file is not downloading with capybara
- Comparing values of Ruby XMLRPC datetime returned from API to normal Ruby DateTime object
- Localized dropdown with all month names
How to nest namspaced resources and avoid double namespacing - uninitialized constant ActsAs::ActsAs Posted: 29 Apr 2016 07:09 AM PDT I have two namespaced models in a Rails app - ActsAs::Comments and ActsAs::Likes. Both are polymorphic, and belong to several different parent models. Improtantly for this question, Likes can belong to a Comment. So my routes look something like this I then have a shared partial, called in the parent object's view, for adding likes. This work's fine for OtherObjects, but not for Comments. Rake routes shows Clicking 'like' gives What is the correct way to set this up and avoid this double namespacing of the controller? |
Running rails project on heroku Posted: 29 Apr 2016 07:13 AM PDT I a little bit new for heroku and postgresql and dont know how works translting from mysql to postgresql. My application was developed on mysql and to run it from heroku i made some steps: 1. Added a And bundle it without production 2. I also changed my database.yml into: (Also i have question, how can i use mysql in devolepment and postgre in production?) But! When i tryed to work via heroku(downloading works fine) my dynamic pages wasnt working, and i get this errors: So, i guessed that DB just doesnt migrate, OK, i runned via console this: My questions: 1. Why it happens? Did i miss some steps when deployed my app? 2. How can i separate production and dev DB in deployment.yml? Thanks, for any help! |
comparing one element in an ActiveRecord array to all others ruby on rails Posted: 29 Apr 2016 07:00 AM PDT I have a simple ActiveRecord query along the lines of this: Each notification object has a field I need to take this Notification's I have a feeling I could do this manually with two nested loops and if statements, but I also know Ruby and I feel like this is something that it should have built in. Am I wrong, or is there a better way to do this? For reference (if it matters) here is how I check for inverse changes: |
wkhtmltopdf not corresponding size after generating pdf Rails Posted: 29 Apr 2016 06:49 AM PDT Iv got a small problem using wkhtmltopdf (wicked_pdf) with rails. This is my pdf after generating. and this is my show action. respond_to do |format| format.html As you can see this is an A4 size page (by default) and Im giving 5 mm margin on each side. The A4 paper have in width 210 mm. Now after Im giving margin of 5mm I'm left with 200mm right? OK In css Im giving to this container a max width of 200mm + those 10 mm of margin should be 210 mm (the size of an A4 page) As you can see in the pic, the generated pdf has way way more mm in width then 210. Any ideas why and how to fix it? If Im setting the width to 100% it will work but that doesnot mean that the width will be 210 mm. |
Whitelist params - how to allow n level nesting of self relationship? Posted: 29 Apr 2016 06:29 AM PDT I've got a use case where employee hierarchies are going to be stored as strings so they can be retrieved in json. (This is a POC, so just a hack for SQLite for now). How can I permit n level of nested objects? In the following example |
How to Encrypt data in ruby same as SecretKeySpec? Posted: 29 Apr 2016 06:19 AM PDT I am trying to encrypt a string in ruby using Cipher with AES algorithm. I have example written in Java. I have taken help from this example and written code in Java but not able to get the same output as in JAVA. Following is the code written in java Output of this code is
I tried to write the same code in ruby. Ruby Code is: Output of this code is
Don't know where is the error. I have already worked for 2 days but not able to get any answer. Any help will be great. Thanks in advance. |
Posted: 29 Apr 2016 06:10 AM PDT Is there a way to use Resque plugins, such as resque-loner, with ActiveJob and Resque as backend for it? |
Cant use class defined inside lib folder in rails app Posted: 29 Apr 2016 07:13 AM PDT I have created a class in my lib folder inside my rails app lib/pundit/current_context.rb : This class is then called in my base_controller : I am always getting : I thought it might be because I am not loading the files inside lib ? so I added Unfortunately I am still getting the error. How can I solve that ? |
Capistrano deployment broken by new request for Capistrano-Harrow gem? Posted: 29 Apr 2016 06:38 AM PDT I thought my capistrano version was locked to 3.4.0, however it seems that it updated to 3.5. I tried going back to 3.4, but I keep getting the following message when I try to deploy my project to server. I'm not familiar with Anyone know how I can either, opt out of harrow to try and get my deploy to work, or correct this issue to move forward? Thanks! Update I ran the following command to "opt-out", however, it still needs to build/install the gem I suppose which is currently the real issue.
|
How to get the records where status is equal to nil and not equal to privilage or casual Posted: 29 Apr 2016 06:09 AM PDT i have a |
Posted: 29 Apr 2016 06:02 AM PDT I have a datetime picker which sends the checkin & checkout dates with search box. Then the url looks like; and I take the params hash and parse the string, first of all, I have to check But if the user manually types something else rather than the date to url such as; Then of course I get an error; How should I control if the string is parsable on controller action. I should be also checking Thank you |
How can I verify username or email are correct using Devise and Rails 4 Posted: 29 Apr 2016 05:15 AM PDT I am using Devise and Rails 4. I am working with login screen. In login screen i'm passing username/email and password but I have to check whether any one of the field username or email matched with any user in system. Tried following condition to find user with username or email but it will be throwing an error for devise valid password method. Condition: after this i'm checking user password as like
For following condition valid_password? will be working fine But i have to check both username and password in Is there some way I can accomplish something like above? |
How to convert all daily datat of a year to monthly data Posted: 29 Apr 2016 05:55 AM PDT First let me tell you what I want, I want to make a chart of a growth of a users mutual funds portfolio. Now I have a user who invests in a portfolio last year. Now I have a task which stores all the daily growth values of a users portfolio in user portfolio growth table. Now as of current date I have all daily values of a portfolio growth in my user portfolio growth table. What I want is to show monthly growth of a users portfolio on a graph. So, my question here is how do I convert all the daily values to monthly values from date of his investment? So, that I can show it on a graph. UserPortfolio Schema UserPortfolioGrowth Thank You! |
Generate array of daily avg values from db table (Rails) Posted: 29 Apr 2016 04:58 AM PDT Context: Trying to generating an array with 1 element for each Result: I've been successful in doing this, but it feels like an unnecessary amount of code to generate the desired result. Code: Question: I think this is a common Or a more optimal way to solve this? (I'm barely a junior developer so any advice you can share would be appreciated!) |
How to use order with uniq in a PostgreSQL Posted: 29 Apr 2016 06:14 AM PDT How can I use The above query gives me following error: This is my scopes scope :item_invoices, ->{ joins(:invoice_details).where("invoice_details.invoiceable_type = ?", "Item")} scope :get_auction_invoices, ->{where(:id => (item_invoices.skip_cancelled_invoice + donators.skip_cancelled_invoice))}
|
rails 4 partial extension required under pdf template Posted: 29 Apr 2016 04:25 AM PDT I have using same partial under two different pages. The first one is under simple Example: I have a partial as views/patient/reports/_invoice.html.haml first Usage:- account.html.haml
second usage:- under invoice.pdf.haml
why do I need to provide file extension in the latter one? |
Error R13 (Attach error) -> Failed to attach to process on running console on heroku Posted: 29 Apr 2016 04:05 AM PDT I want to run rails console on heroku by typing command "heroku run rails console -a getpayad-staging" , but it kept on running and in logs i came up with error "Error R13 (Attach error) -> Failed to attach to process". I have seen couple of answers but not find perfect answer. |
ruby on rails rest api with ruby for login page Posted: 29 Apr 2016 04:22 AM PDT i want to implement a ruby api for login page with ruby on rails backend in android mobile application, As i am new to this kindly help me to complete my task, and please tell the way to implement an API Thanks in advance |
Cannot use password grant_type on 4.0.0 RC3 using Rails 5 Beta Posted: 29 Apr 2016 03:41 AM PDT I am trying to use doorkeeper on my Rails 5 app, and want to grant using password grant flow. Versions used to do this is
I followed the intstructions here, and when I send a grant_type=password to the /oauth/token, I get an error. I tried this with a Rails4 app with doorkeeper 3.1.0, and had no problems. I have created a new app and did the initial setup for doorkeeper, and have used the chrome extension called Advanced REST Client and the curl command to try to send username and password. Have uploaded sample app on github. |
How to show entries from the current month? Posted: 29 Apr 2016 03:44 AM PDT For the sake of explanation, I'm writing an app where a User can log their expenses. In the User's show view, I want to only show the User's expenses from the current month. My expenses table looks like this: The date field is in the date format, so looks like: In my controller, I've got something like: Obviously, this isn't going to work, but it will be something along these lines, I'm guessing? Any help would be great, thanks! |
Ruby issue while configuring sensu checks Posted: 29 Apr 2016 04:22 AM PDT I have sensu server and sensu-client Installed on one machine (centos) and installed the the plugins through gem. Everything was good when I run the I have ruby installed of 1.9.3 version and configured when I check the UI the below is the error I am facing Can someone help with this? |
capistrano excute Makefile fail Posted: 29 Apr 2016 03:38 AM PDT I have a problem with excute Makefile deploy.rb: Makefile: error when run "cap production deploy" Debug run direct on server "make production" => echo "make file production" And if excute with only "make" it will running to the first tag --- Makefile addition |
Unable to establish relationship between two objects in Rspec Posted: 29 Apr 2016 02:57 AM PDT I'm writing an RSpec called Leads controller spec. In that I'm writing a test for create action of lead controller. Now my lead controller calls Project model to create an object(Project) which also creates Contact object and assigns it to project. but when I try to test whether my Project model creating a Contact object or no, The tests are getting failed. I don't know why my contact object is not getting created:( My leads_controller_spec.rb leads_controller.rb Project.rb contact_fabricator.rb project_fabricator.rb contact.rb |
Unable to download .docx file using Capybara in ruby [duplicate] Posted: 29 Apr 2016 02:56 AM PDT This question is an exact duplicate of: I am trying to download the .docs file by using capybara in ruby but all file is getting download except .docx. so plz tell me how can i download the .docx file using ruby profile = Selenium::WebDriver::Firefox::Profile.new profile['browser.download.dir'] = '/tmp/' profile['browser.download.folderList'] = 2 profile['browser.helperApps.neverAsk.saveToDisk']="images/jpeg,application/pdf, application/doc, application/docx, text/csv, application/octet-stream" profile['pdfjs.disabled'] = true profile.native_events = true @driver = Selenium::WebDriver.for :firefox, profile: profile puts '===============> Download will start now ===================>' @driver.get link puts '===============> Download is over ===================>' |
belongs_to with different foreign key as well as primary key in the other table Posted: 29 Apr 2016 02:56 AM PDT I have two models:
A ticket belongs_to a User, and a User has_many Tickets. The thing here is that I want to associate these two models with: The ticket has a How can I set the association to accomplish this (basically I want to specify the columns that set the association. In this case they are different than the primary keys). I have this now: And I am able to do |
Create a auth user using devise Posted: 29 Apr 2016 03:58 AM PDT Im using User.rb routes.rb callbacks_controller.rb I also ran the correct migration to add provider and uid column to the users table config/initializers/devise.rb When i create a user using problem is github user can login but they are not being created as users, using their github credentials, i need users to login and create a profile with me. |
Posted: 29 Apr 2016 06:47 AM PDT I am using Elasticsearch version 2.3.1 for the search along with Ruby On Rails . I am using query_string for the search . It calculates the score on the basis of three factors :- 1.Term Frequency 2.Inverse document frequency 3.Field-length norm I just want Term Frequency to be used for calculating score . Any way by which i could disable Inverse document frequency and Field-length norm factor in calculating score . After some R&D on the topic i came with constant_score query which indirectly gives weightage to Term Frequency . The problem which I know facing is that : e.g If i search for "good street food" it treats document having only "good" ,or "good food", or completely "good street food" with same score . But I want document with "good street food" should have higher score than "good food" , "good food" score higher than "good" . The One solution which I came across is : This some how solve my problem as know i am treating every word as different query rather than full string . But If someone has any better and optimize solution than this in which i could enter entire string in one line rather than loop and it gives priority to that document which has best matching or contains some word multiple times would love to know about that solution. |
.docx file is not downloading with capybara Posted: 29 Apr 2016 04:34 AM PDT I am trying to download the .docs file by using capybara in ruby but all file is getting download except .docx. so plz tell me how can i download the .docx file using ruby |
Comparing values of Ruby XMLRPC datetime returned from API to normal Ruby DateTime object Posted: 29 Apr 2016 02:51 AM PDT I have an XMLRPC datetime returned from a remote API, and I want to perform normal comparison operations to a standard Ruby datetime object, such as >, <, >=, etc. I've read that XMLRPC has some strange datetime restrictions (such as it doesn't support values before or after a certain date) and using DateTime.parse() for the returned object doesn't work, with or without string interpolation. How do you accurately convert an XMLRPC::DateTime object to a standard Ruby 2.2.2 DateTime object so I can execute comparisons, regardless of the date returned? |
Localized dropdown with all month names Posted: 29 Apr 2016 05:34 AM PDT I am trying to make in Rails 4 a dropdown with all the months. I do it like this: The problem now is that I would like to localize it, but I can't apply the How could I solve this? Update I know I can translate them myself, but I was hoping, since Rails is so kind to give me the names in English, if there was any way that Rails could give it to me in other languages as well. |
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