I am trying to save a record into a collection using autoform and although I have several other forms that work fine this new one is giving me a access denied error when I use the same permissions as my other already working collections.
Although if I set the allow to just return true, the record inserts momentarily (watching in mongol) then is deleted. Why is this?
My allow file:
Posts.allow
insert: (userId, doc) ->
userId == doc.owner # all works fine for the other forms..
update: (userId, doc, fields, modifier) ->
userId == doc.owner
remove: (userId, doc) ->
userId == doc.owner
purchaseOrders.allow
insert: (userId, doc) ->
userId == doc.owner #setting to true momentarily inserts and then is deleted
update: (userId, doc, fields, modifier) ->
userId == doc.owner
remove: (userId, doc) ->
userId == doc.owner
Autoform template
{{#autoForm collection="purchaseOrders" type="insert" id="confirmPurchaseOrder"}}
{{> afQuickField name="message" rows=4 type="textarea" style="width: 100%;"}}
<button type="submit" class="btn btn-success" id="confirmOrderFinal">Confirm Order</button>
{{/autoForm}}
Collection
@purchaseOrders = new Meteor.Collection('purchaseOrders');
Schemas.purchaseOrders = new SimpleSchema
message:
type: String
label: "Extra message or instructions"
optional: true
autoform:
afFieldInput:
type: "textarea"
rows: 4
status:
type: String
optional: true
orders:
type: Array
optional: true
"orders.$":
type: Object
createdAt:
type: Date
autoValue: ->
if this.isInsert
new Date()
updatedAt:
type:Date
optional:true
autoValue: ->
if this.isUpdate
new Date()
owner:
type: String
regEx: SimpleSchema.RegEx.Id
autoValue: ->
if this.isInsert
Meteor.userId()
autoform:
options: ->
_.map Meteor.users.find().fetch(), (user)->
label: user.emails[0].address
value: user._id
Thanks for any help on why this wont insert as this is the last thing to finish my app! hope someone can help out there