rabl

symlink() NotImplementedError rabl

此生再无相见时 提交于 2020-01-25 21:29:44
问题 Adding to gemfile failed and hence I tried gem install rabl . It fails with the following error message, looks like its OS specific... I'm on Windows 7 and using Ruby 2.2 on Rails 5 api G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:388:in `symlink': symlink() function is unimplemented on this machine (NotImplementedError) from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems/package.rb:388:in `block (2 levels) in extract_tar_gz' from G:/Ruby/ruby/lib/ruby/site_ruby/2.2.0/rubygems

How can I pass an object to rabl views from rake task

吃可爱长大的小学妹 提交于 2020-01-14 02:46:26
问题 I am trying to create a json file from a rake task using rabl. Below I have the simplified version to test with. When I view 'articles.json' or 'articles/2.json' via the url, I get the expected json response. But when I try to run it via the rake task, it always has a null value for @articles in the jsonFile created. It will render the index.json.rabl view the same number of times as @articles.count, but the values are always null. So how do I pass in the @articles object created in my rake

Rails 4 - How to render JSON regardless of requested format?

自闭症网瘾萝莉.ら 提交于 2019-12-29 04:37:07
问题 I'd like a Rails controller (all of them, actually, it's an API) to render JSON always always. I don't want Rails to return "route not found", or try and fail to find an HTML template, or return 406. I just want it to automatically and always render JSON, e.g. from a RABL or JBuilder view. Is this possible? Related questions seem to have answers that have the aforementioned downsides. 回答1: You can add a before_filter in your controller to set the request format to json : # app/controllers

Rails RABL respond_with error template

二次信任 提交于 2019-12-22 13:58:10
问题 Using RABL in Rails 3.2.x, given the following controller action: respond_to :html, :json def create @foo = Foo.create(params[:foo]) respond_with @foo end Assuming the validation fails, how do you get respond_with to use a RABL template instead of the standard JSON hash of errors -- IE. I would like other model attributes besides the validation error message sent back along with the request. Suggestions? 回答1: I found this one out the hard way. You should create a custom responder for your

Accessing the child instance in a RABL template

依然范特西╮ 提交于 2019-12-19 04:04:13
问题 I have a RABL template as shown below object @user attributes :name child :contacts do # does not work if contact.is_foo? attributes :a1, :a2 else attributes :a3, :a4 end end How do I access the Contact object in the child block of the template? I need to perform some conditional logic on the child instance. 回答1: You can access the current object by declaring the block parameter. object @user attributes :name child :contacts do |contact| if contact.is_foo? attributes :a1, :a2 else attributes

Incomplete response body being returned from Rails 3 app with RABL

 ̄綄美尐妖づ 提交于 2019-12-18 06:16:33
问题 I've built a JSON API using Rails 3 and RABL The API works well but on particular requests only part of the data is returned - the rest of the JSON is cut off. Since the JSON is therefore invalid, the mobile app which relies on the API is crashing. Can anybody think of why the body is cut off at a certain size and point me in the right direction to resolve the issue? Thanks 回答1: So I was able to track this issue down to Passenger Long story short I fixed it by setting passenger_buffer

Does RABL's JSON output not conform to standard? Can it?

走远了吗. 提交于 2019-12-13 04:47:04
问题 So I have a very simple rabl view that will support output for both xml and json (curr.rabl): collection @currencies => "currencies" attributes :code, :name My rabl config: Rabl.configure do |config| config.include_json_root = false config.include_child_root = false config.xml_options = { :skip_types => true, :camelize => :lower } config.include_xml_root = false end Output that rabl gives for xml and json: XML: <currencies> <currency> <code>AFN</code> <name>Afghan Afghani</name> </currency>

Calling Rails helper from rabl Rails

落花浮王杯 提交于 2019-12-11 09:55:19
问题 I'm trying to call a Rails helper from my rabl template, but it's not working. I have an image object and I want to pass its pass through my api. So then image path should have the full url (Ex: http://<my url>/uploads/myimage.jpg ). The host part I want to add through a Rails helper. #my rabl file object @image attributes :id, :picture_url What I want is something like (I tried this but doesn't work) #my rabl file object @image attributes :id, full_url(:picture_url) #app/helpers/application

why won't rails find rabl templates?

懵懂的女人 提交于 2019-12-11 03:08:17
问题 working on an api, using the rails-api and rabl gems, basing understanding off railscasts 348 and 322 currently getting Missing template activities/index, application/index with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :rabl]}. Searched in: * "/Users/jd/Dropbox/honeybadgerconsulting/activitiesapi/app/views" but best I can tell, my setup mirrors the screencasts, is there a detail i'm overlooking ? controller is class ActivitiesController <

Rabl, remove parent element of children

喜欢而已 提交于 2019-12-11 01:02:00
问题 could anyone help me get rid of the "item" element within "items the output should be: "list":{ "items":[ { { data1: "test" } , { data2: "test2" } } } collection @list child :items => :items do attributes :place_id end child :items do child :place do |place| extends 'places/place', object: place end end current output: "list":{ "items":[{ "item":{data1: "test"} "item":{ data2: "test2"}}} 回答1: I had the same problem and this was the solution. You may need to create the file named to configure