Search Posts

Category: ruby-on-rails

Factory code not firing in $stateProvider onEnter AngularJS and Rails

I’m having an issue with specific code in a factory not firing within the $state onEnter in ui-router. I’m using ui-router/angularJS in my rails app, and everything works great. However, when I navigate to the URL directly, or I refresh the page, everything breaks. Essentially, hard GETs do not work when html5Mode is enabled in UI-router. After doing a ton of research, I found this as a potential solution: https://gist.github.com/adambarthelson/60ad5a1c7a4ef6d8d893 This does not work, however. […]

How to remove # from Angular App?

I have an Angular Application (Angular 5) as well as Ruby on rails backend. I put my angular app in the ruby-on-rails public folder and its working fine with a ‘#’ prefix. Now, I want to remove that ‘#’ Prefix. When I remove it, I am getting errors. I’ve deploy ruby-on-rails application on EC2 with Apache2 and Passenger. This is my PATH for .htaccess file /var/www/ro-blog/.htaccess Can anyone please help me – How can I […]

What’s the difference between < and @ scope isolation in angularJS?

My Rails app has different organization with their profile page with their own inventory stats table. Written below is the part of app/views/organization/show.html.erb <div ng-app=”cc-app” class=”card-body overflow-hidden”> //codes here <inventory-stats orgid=”<%= @organization.id %>”> </inventory-stats> //codes here </div> I have made a directive to show inventory stats and pass orgid i.e Organization ID with scope isolation(one-way binding) to get organization’s inventory stats. As far as I know I have two ways of defining scope object for […]

ng-strict-di doesn’t recognise ‘ngInject’

I’m using Rails 4.0 with AngularJS 1.5 and the ng-annotate gem. I’ve noticed that when I put on the ‘ng-strict-di’ which forces you to annotate all your direct injections in AngularJS I find that Rails complains about modules which have “ngInject” in place. eg; Here is my application controller for Angular ApplicationController = ( $scope, $timeout, hotkeys ShortcutService) -> “ngInject” <SNIP> I have ng-strict-di enabled in my template <html ng-app=’paisApp’ ng-strict-di> When I run my […]

delete 1 object angularjs 1 from rails server

guys, I tried to delete 1 object from massif. Massif storage on rails server. You can see it localhost/vms {“success”:true,”vms”:[{“name”:”test”}, {“name”:”dfdfdfd”}]} And i need to delete “test”(first object from massif). How can i do this? When i used, I got a rails error, that ActionController::RoutingError (No route matches [DELETE] “/vms”): $http.delete(‘localhost/vms’, name) routes.rb Rails.application.routes.draw do resources :vms, only: [:index, :create, :delete], defaults: { format: ‘json’ } end Source: AngularJS

Rails – AngularJS : search data with parameter

I’m using Typeahead to suggest a list when user start type some thing on the input text, I want to decrease the requests and data number returned from the api to frontend side, the idea is to send a parameter (which is what the user start type in the text input) to the api and depend on that parameter the controller filter data and send it to angularJS side . API controller : class Api::V1::Angular::SpecificationTemplatesController […]

upload pdf file with ruby on rails

My sites need to upload files like pdf, docx, xlsx, csv types. Im trying send this files types with paperclip or carriewave but without success. Controller.rb def uploader organ = Admin::Organ.find(params[:organ_id]) organ.attachment = params[:file] render json: organ.save end def uploader_file organ_file = Admin::Organ.find(params[:organ_id]) organ.report = params[:file] render json: organ_file.save end organ.rb mount_uploader :report, ReportUploader validates_processing_of :report validate :file_size_validation private def file_size_validation errors[:report] << “Tamanho deve ser menor que 500 Mb” if report.size > 0.5.megabytes end […]

Angular + rails : How to define different route for two angular application created inside a rails application

I am using angular1.x and rails 5.0.1. I am newbie to angular. I have created two client(angular) applications. One for simple user and other for admin user. How can i define the different routes for admin and client such that when admin try to access then admin/index.routes.js should be called. What is happing now it always calls client/index.routes.js. Can anyone please help me, how can i define different routes. Remember: I have two index.routes.js files […]

AngularJS typeahead with ruby on rails api

I’m working on an advanced project and trying to integrate Typeahead with angularJS using CoffeeScript syntax and rails api, I created a route that return a json resource. I want to get this result in angularJS side and implement it to let typeahead suggest a list for user when write some thing in the This is the method how it looks like : # GET /api/v1/angular/contract_periods/specification_templates_names def get_templates_names specification_templates_names = SpecificationTemplate.current .pluck( :name ) .uniq […]

Next Page »