'Rails passing integer value from view to controller

I have to add a view where user will enter a number and we will respond according to that number. Here I am asking a number from user and if he submit it we will generate number of paragraph for that.

Getting error undefined method `each' for nil:NilClass in _show_data.html.erb file

Application Controller

class ApplicationController < ActionController::Base
private
    def baconipsum
        @baconipsum ||= Faraday.new("https://baconipsum.com/") do |f|
          f.response :json
        end
      end
end

Articles Controller.rb

def showData
    @value = params[:value] 
@bacon = baconipsum.get("api/", type: 'all-meat',paras: @value).body
  end

_form_data.html.erb

<%= form_for:article do %>
    <label for="value">Value</label>
    <%= text_field_tag :value %>
    <%= submit_tag "Submit" %>
<% end %>

_show_data.html.erb

    <% @bacon.each do |meat| %>
  <p><%= meat %></p>
<%end%>


Solution 1:[1]

If you want all profiles to be readable by any signed in user, but only modifiable by the user whose UID equal the document ID, your rules look mostly OK.

The only thing to change is indeed what you already wondered: ensuring that signed in users can also only create their own document. So:

match /profiles/{userId} {
  allow read: if request.auth != null;
  allow create, update, delete: if request.auth != null && request.auth.uid == userId;
}

Which can be simplified to:

match /profiles/{userId} {
  allow read: if request.auth != null;
  allow write: if request.auth != null && request.auth.uid == userId;
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Frank van Puffelen