rails-api

rails active_storage:install IS NOT WORKING

半城伤御伤魂 提交于 2019-11-30 20:08:01
I have updated my rails api application from 5.1 to 5.2. I am using rails api only. I am trying to use the active storage. I think the problem is due to the line config.api_only = true in config/application.rb . I did lot of google but did not find any thing how to use active storage in rails api. Here is my Gemfile : source 'https://rubygems.org' ruby '2.5.1' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" end gem 'rails', '~> 5.2.0' gem 'pg', '>= 0.18', '< 2.0' gem 'puma', '~> 3.7' gem 'rack-cors'

What is the difference between a regular Rails app and a Rails API?

醉酒当歌 提交于 2019-11-30 14:21:28
In the process of learning Rails, I read about how we could combine it with some front-end MV* JavaScript frameworks — such as Backbone.js, Angular.js, or Ember.js — to improve the UX. This introduced (to me) the concept of using Rails as an API, instead of a web app. So, now, I am pretty confused: what is the difference between a regular Rails app and a Rails API? Cyril Duchon-Doris A regular Rails app will use the rails views (erb or haml) to render pages directly. That is to say, it will process the data AND render this data in views, answering directly the client request with a HTML page.

Correct way to implement API versioning with active_model_serializers

橙三吉。 提交于 2019-11-30 05:48:28
I know there are already some questions and also this is a open issue regarding AMS not handling namespaces too efficiently (which is used by this versioning approach) but I wanted to be sure I am in the right track within the current constraints. Right now I am using Rails 5 and AMS 0.10.1, so I did the following: # config/initializers/active_model_serializer.rb ActiveModelSerializers.config.serializer_lookup_enabled = false to disable default serializer lookup (which didn't work anyway); and # app/controllers/application_controller.rb class ApplicationController < ActionController::API def

emberjs handle 401 not authorized

允我心安 提交于 2019-11-30 05:19:08
I am building an ember.js application and am hung up on authentication. The json rest backend is rails. Every request is authenticated using a session cookie ( warden ). When a user first navigates to the application root rails redirects to a login page. Once the session is authorized the ember.js app is loaded. Once loaded the ember.js app makes requests to the backend using ember-data RESTadapter and the session for authorization. The problem is the session will expire after a predetermined amount of time. Many times when this happens the ember.js app is still loaded. So all requests to the

rails active_storage:install IS NOT WORKING

会有一股神秘感。 提交于 2019-11-30 03:47:14
问题 I have updated my rails api application from 5.1 to 5.2. I am using rails api only. I am trying to use the active storage. I think the problem is due to the line config.api_only = true in config/application.rb . I did lot of google but did not find any thing how to use active storage in rails api. Here is my Gemfile : source 'https://rubygems.org' ruby '2.5.1' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo

How do I select which attributes I want for active model serializers relationships

女生的网名这么多〃 提交于 2019-11-30 03:45:18
问题 I am using the JSONAPI format along with Active Model Serializers to create an api with rails-api. I have a serializer which shows a specific post that has many topics and currently, under relationships, lists those topics. It currently only lists the id and type. I want to show the title of the topic as well. Some would say to use include: 'topics' in my controller, but I don't need the full topic record, just its title. Question : How do I specify which attributes I want to show from topics

What is the difference between a regular Rails app and a Rails API?

孤街醉人 提交于 2019-11-29 20:02:23
问题 In the process of learning Rails, I read about how we could combine it with some front-end MV* JavaScript frameworks — such as Backbone.js, Angular.js, or Ember.js — to improve the UX. This introduced (to me) the concept of using Rails as an API, instead of a web app. So, now, I am pretty confused: what is the difference between a regular Rails app and a Rails API? 回答1: A regular Rails app will use the rails views (erb or haml) to render pages directly. That is to say, it will process the

Correct way to implement API versioning with active_model_serializers

一曲冷凌霜 提交于 2019-11-29 03:56:21
问题 I know there are already some questions and also this is a open issue regarding AMS not handling namespaces too efficiently (which is used by this versioning approach) but I wanted to be sure I am in the right track within the current constraints. Right now I am using Rails 5 and AMS 0.10.1, so I did the following: # config/initializers/active_model_serializer.rb ActiveModelSerializers.config.serializer_lookup_enabled = false to disable default serializer lookup (which didn't work anyway);

emberjs handle 401 not authorized

谁说我不能喝 提交于 2019-11-29 02:52:32
问题 I am building an ember.js application and am hung up on authentication. The json rest backend is rails. Every request is authenticated using a session cookie (warden). When a user first navigates to the application root rails redirects to a login page. Once the session is authorized the ember.js app is loaded. Once loaded the ember.js app makes requests to the backend using ember-data RESTadapter and the session for authorization. The problem is the session will expire after a predetermined

undefined method `flash' for ActionDispatch::Request

余生长醉 提交于 2019-11-28 20:25:32
I'm trying to write an Ember application in Rails 4, and have decided to go with rails-api for the api controllers, while keeping the application controller intact for a few pages that aren't part of the single-page app. To put it in more concrete terms, here are my controllers: app/controllers/application_controller.rb : class ApplicationController < ActionController::Base protect_from_forgery end app/controllers/sample_controller.rb : class SampleController < ApplicationController # my methods end app/controllers/api/v1/api_controller.rb : class Api::V1::ApiController < ActionController::Api