title: getting id from inside controller rails
body: <p>I'm new to rails so I don't know the correct terminology.
  I'm trying to get an id of a community from my subscription controller but I'm getting the error <code>undefined method 'community_id' for nil:NilClass</code></p>
  <p>my <code>SubscriptionController.rb</code>:</p>
  <pre><code>class SubscriptionsController &lt; ApplicationController
  
      def create
          @subscription = Subscription.new(subscription_params)
          @subscription.account_id = current_account.id
          @subscription.save
          redirect_to community_path(@subcription.community_id)   //error here
          redirect_to community_path(params[:community_id])   // also error below
          end
      end
      
      def subscription_params
          params.require(:subscription).permit(:community_id)
  end
  </code></pre>
  <p>error from 2nd line try: <code>No route matches {:action=&gt;&quot;show&quot;, :controller=&gt;&quot;communities&quot;, :id=&gt;nil}, missing required keys: [:id]</code>.</p>
  <p>The subscription is saving into the db. What am I doing wrong?</p>